You were right. So, I did:
EditProfileForm:
public $bday, $bmonth, $byear;
protected function afterFind() { // public function beforeGetter() ?
list($this->byear, $this->bmonth, $this->bday) = explode('-', $this->birthday);
$this->bday=intval($this->bday);
$this->bmonth=intval($this->bmonth);
return parent::afterFind();
}
protected function beforeValidate() {
$this->birthday = date('Y-m-d',strtotime($this->bday.'-'.$this->bmonth.'-'.$this->byear));
return parent::beforeValidate();
}
$this->bday=intval($this->bday); is a key to happiness ^^.
My view goes like this:
<?php echo CHtml::activeLabel($model,'birthday'); ?>
<?php
echo CHtml::activeDropDownList($model, 'bday', DateHelper::getDays(), array('prompt' => 'День'));
echo CHtml::activeDropDownList($model, 'bmonth', DateHelper::getMonths(), array('prompt' => 'Месяц'));
echo CHtml::activeDropDownList($model, 'byear', DateHelper::getYears(), array('prompt' => 'Выберите год'));?>
<?php echo CHtml::error($model,'birthday'); ?>
class DateHelper extends CComponent{
public static function getMonths() {
$m=array('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь');
return array_combine(range(1,12),$m);
}
public static function getDays() {
return range(1,31);
}
public static function getYears() {
return array_combine($a=range((date('Y') - 16),(date('Y') - 60)),$a);
}
p.s.
getYears() returns only those values registration policy allows.