有没有办法将CJuiDatePicker验证为必填字段?
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'model'=>$model,
'attribute'=>'bdate',
'options'=>array(
'showAnim'=>'fadeIn',
'dateFormat'=>'mm/dd/yy',
'changeMonth'=>true,
'changeYear'=>true,
'minDate'=>'01/01/1900',
'yearRange' => '-200:+0',
'maxDate'=>'0',
),
'htmlOptions'=>array('readonly' => true, 'class' => "form-control", 'required'=> 'true', 'value'=>isset($_SESSION["bdate"])?$_SESSION["bdate"]:'')
));
?>
谢谢!
答案 0 :(得分:0)
简单声明&#34; bdate&#34;作为模型中的必需属性:
public function rules()
{
return array(
...
array('bdate', 'required'),
...
);
}
有问题吗?