如何在 Yii 中的 CJuidatepicker 中添加默认值?

hd.*_*hd. 1 jquery-ui yii jquery-ui-datepicker zii-widgets yii-widgets

我有下面的代码以 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',
                ),  
              )); 
 ?>
Run Code Online (Sandbox Code Playgroud)

默认值适用于日历,但我想在表单渲染时默认在日历输入中显示它。

我该怎么做?

Man*_*uer 5

您可以为此使用 Html value 属性

<?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')
              )); 
Run Code Online (Sandbox Code Playgroud)