想知道是否有人可以提供帮助。
我的数据库中有一个DOB字段,我的表单正在填充。我们做了一些工作,使它更加友好,并确保我们以正确的格式获得出生日期,然而,当我再去更新表格时,它没有重新解释DOB领域。
这是我的代码;
模型
public $year;
public $month;
public $day;
模型 - >规则()
array('day','length', 'max'=>2),
array('day','length', 'min'=>2),
array('day', 'numerical','integerOnly' => true, 'min' => 1 ),
array('year','length', 'max'=>4),
array('year','numerical','integerOnly' => true, 'min' => 4),
protected function afterFind() {
$dob = explode('/', $this->dob);
$this->year = $dob[0];
$this->month = $dob[1];
$this->day = $dob[2];
parent::afterFind();
}
模型 - >添加到beforesave()
$this->dob = $this->year .'/'. $this->month .'/'. $this->day;
在视图中_Form
echo $form->textFieldGroup(
$user,
'day',
array(
'widgetOptions' => array(
'htmlOptions' => array(
'placeholder' => 'DD')
)
)) ;
echo $form->dropDownListGroup(
$user,
'month',
array(
'widgetOptions' => array(
'data' => array('01' => 'January' , '02' => 'February' , '03' => 'March' , '04' => 'April' , '05' => 'May' , '06' => 'June' , '07' =>'July' , '08' =>'August' , '09' =>'September' , '10' =>'October' , '11' =>'November' , '12' =>'December'),
// 'data' => 'Jan','Feb';
'htmlOptions' => array(
'class' => 'col-md-3 ',
'prompt' => 'Choose month',
),
)
)
);
echo $form->textFieldGroup(
$user,
'year',
array(
'widgetOptions' => array(
'htmlOptions' => array(
'placeholder' => 'YYYY',
'class' => 'col-md-3',
)
)
));
相同的观点显然对于更新,但我需要一些东西让actionUpdate爆炸数据并将其放回下拉列表中
有没有人对最简单的方法有任何想法?