Add Datepicker In Form

I just learned how to add datepicker in form.


echo $form->labelEx($model,'datecolumn name');

The Above line display label for date column.


$this->widget('zii.widgets.jui.CJuiDatePicker',array(

				'name'=>'Modelname[datecolumn name]',

				'id'=>'Modelname_datecolumn name',

			    'value'=>Yii::app()->dateFormatter->format("d-M-y",strtotime($model->datecolumn_name)),

				'options'=>array(

    				'showAnim'=>'fold',

				),

				'htmlOptions'=>array(

    				'style'=>'height:20px;'

				),

			)); 

from the above lines,

name and id attributes are represent html attributes [name,id] of the input.

value option displays saved date during edit / update operation.

THnxxxxxxxx…it works fine <><>

Thnx itz wworks for me too

This is work for me too. Thanks

so great, thanks

You save my times. Thanks!

:( this doesn’t works for me… no data is being saved in the database

<div class="row">

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'arrival'); ?&gt;


	&lt;?php &#036;this-&gt;widget('zii.widgets.jui.CJuiDatePicker',array(


                            'name'=&gt;'arrival',


                            'id'=&gt;'arrival',


                        'value'=&gt;Yii::app()-&gt;dateFormatter-&gt;format(&quot;d-M-y&quot;,strtotime(&#036;model-&gt;day_nos)),


                            'options'=&gt;array(


                            'showAnim'=&gt;'fold',


                            ),


                            'htmlOptions'=&gt;array(


                            'style'=&gt;'height:20px;'


                            ),


                    )); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'arrival'); ?&gt;


&lt;/div&gt;

Please Help :unsure:

The Date picker is coming fine but Date Format is changing when i change the date

Initially it appearing in 2015-03-11 format late changing to 03/11/2015.

Please provide some alternative solution.

[
‘attribute’ => ‘post_date’,
‘value’ => ‘post_date’,
‘format’ => ‘raw’,
‘filter’ => DatePicker::widget([
‘model’ => $searchModel,
‘attribute’ => ‘post_date’,
‘options’ => [
‘id’ => ‘datepickerT’
],
‘clientOptions’ => [
‘autoclose’ => true,
‘format’ => ‘yyyy-mm-dd’,
]
]),
], correct the format if any one needs it