下面的代码显示Yii格式的日历输入。
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'publish_date',
'attribute' => 'publish_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'defaultDate' => '2014-3-4',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,
'appendText' => 'yyyy-mm-dd',
),
));
?>默认值在日历上工作,但在窗体呈现时,默认情况下也要在日历输入中显示它。
我该怎么做呢?
发布于 2014-05-21 09:51:00
您可以为此使用Html值属性。
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'publish_date',
'attribute' => 'publish_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'defaultDate' => '2014-3-4',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,
'appendText' => 'yyyy-mm-dd',
),
'htmlOptions'=>array('value'=>'2013-4-4')
)); 发布于 2017-08-12 11:28:33
Manquer的解决方案不起作用(在1.1.17版中),CJuiDatePicker从CJuiInputWidget扩展而来,它有一个value属性,在呈现元素时由CHtml::inputField()使用,覆盖htmlOptions属性的value字段。
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'publish_date',
'attribute' => 'publish_date',
'model'=>$model,
'options'=> array(
'dateFormat' =>'yy-mm-dd',
'defaultDate' => '2014-3-4',
'altFormat' =>'yy-mm-dd',
'changeMonth' => true,
'changeYear' => true,
'appendText' => 'yyyy-mm-dd',
),
'value' => '2013-3-4',
));https://stackoverflow.com/questions/23779397
复制相似问题