CJuiDatePicker

Hello, I am using this datepicker for my _form.php view file, which puts it in both the create and update pages. I defined it as:


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

		'name'=>'Stories[date]',

		'value'=>$model->date,

));

This works great for the update.php view, which places as a default value the existing date. However, for the create page, it puts 0000-00-00, instead of just an empty string. Any parameter to make it use blank on create.php, like how $form->textField() automatically does? Thanks.

use the model and attribute properties instead of name and value

I tried that but it still defaults to 0000-00-00 in the update view, and I don’t even have anything in the model or controller that sets that default value…

This is strange. What version of Yii are you using?

Could you post the controller, model and view of this example?

Hello guys. It seems that CJuiDatePicker works wrong.

I used CRUD generator in order to generate controller and view. Then I changed


$form->textField($model,'date_start');

to


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

                            'name'=>'date_start',

                            'model'=>$model,

                            'attribute'=>'date_start',

                            'value'=>$model->date_start,

                            // additional javascript options for the date picker plugin

                            'options'=>array(

                                'showAnim'=>'fold',

                                'dateFormat'=>'yy-mm-dd'

                            ),

                            'htmlOptions'=>array(

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

                            ),

                        ));

But when I choose date and press submit, form’s validator shown me error message: “Date Start cannot be blank.” And I decided to check the “value” attribute of input field which used by zii.widgets.jui.CJuiDatePicker, and it was empty. Even more it was absent. Btw I use Yii 1.1.6.

Can anyone help me to solve this problem?

I posted an example of how to use the CJuiDatePicker Here

thank you so much :)

it helped me :)

i haved tried but not change this value 1970/01/01 07:00:01 AM

this my code

<div class="row">

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


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


	'model'=&gt;&#036;model,


	'attribute'=&gt;'time',


	'options'=&gt;array(


		//'showAnim'=&gt;'slideDown', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'


		'showOn'=&gt;'button', // 'focus', 'button', 'both'


		'buttonImage'=&gt;Yii::app()-&gt;request-&gt;baseUrl.'/images/calendar.png', 


		'buttonImageOnly'=&gt;true,


		'htmlOptions'=&gt;array('readonly'=&gt;&quot;readonly&quot;),


		'changeMonth'=&gt;true,


		'changeYear'=&gt;true,


		'mode'=&gt;'datetime',


		'dateFormat'=&gt;'dd/mm/yy',


		'htmlOptions'=&gt;array(


			'size'=&gt;43,


			'value'=&gt;(&#33;empty(&#036;model-&gt;time))?(is_numeric(&#036;model-&gt;time))?date('d/m/Y',&#036;model-&gt;time):&#036;model-&gt;time:date('d/m/Y')),


           


	)));?&gt;


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


 &lt;/div&gt;

can you help me?

Old problem… still persistent.

My solution was to change mysql schema like


ALTER TABLE  `safefleet_share` CHANGE  `ending`  `ending` TIMESTAMP NULL DEFAULT NULL