Our forms often require users to input time. There is a very convenient time control CJuiDatePicker in Yii for use. The result is as follows:
Call method
[php]
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'language'=>'zh_cn',
'name'=>'worktime[start]',
'value'=>$query['start'] ? $query['start'] : Date('Y-m-d'),
'options'=>array(
'showAnim'=>'fold',
'showOn'=>'both',
'buttonImage'=>Yii::app()->request->baseUrl.'/images/calendar.gif',
'maxDate'=>'new Date()',
‘buttonImageOnly’=>true,
'dateFormat'=>'yy-mm-dd',
),
'htmlOptions'=>array(
'style'=>'height:18px',
‘maxlength’=>8,
),
));
?>
The html code obtained by the above code is as follows:
[html]
Parameter description in CJuiDatePicker
name: name
in input tag
value: value
in the input tag
options: Mainly related to calendar control display
showAnim: the animation effect that appears in the calendar box, optional values are slideDown, show(the default), slideDown, fadeIn, fold, etc.
ShowOn: How to trigger the calendar box, both: click on the icon or input box; focus: click on the input box; button: click on the icon
buttonImage: Icon image address
maxDate: The optional maximum date, corresponding to minData
dateFormat: Calendar data format. Note that the date format of the above value must be consistent with this, otherwise the data will not match the control.
htmlOptions: Some html settings for the input box, such as style, maximum length, etc.
Note:
For more other parameters, you can refer to the jquery datepicker manual, and then put them in the options above and enclose them in single quotes.