Date Picker

Hi,

First off, I’m very new to using Yii. I’m working on my first project with it now.

I’m trying to use the CJuiDatePicker found here:http://www.yiiframework.com/doc/api/1.1/CJuiDatePicker

I was able in insert the code and have it render successfully on a CActiveForm however I can’t seem to have it relate back to the model successfully. It shows up and I can choose a date but when I hit save it won’t get saved back to the database.

I’ve tried using the ‘model’ value as well as ‘id’ and ‘name’.

Here is the bit where I’m trying to use it:


          <?php echo $form->labelEx($model,'calendarDay'); ?>

		<?php //echo $form->textField($model,'calendarDay'); ?>

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

                    'id'=>'calendarDay',

                    'name'=>'calendarDay', 'value'=>$model->calendarDay, 'model'=>$model,

                    // additional javascript options for the date picker plugin

                    'options'=>array(

                        'showAnim'=>'fold',

                    ),

                    'htmlOptions'=>array(

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

                    ),

                ));?>

		<?php echo $form->error($model,'calendarDay'); ?>

Any help would be greatly appreciated.

Thanks,

-Nazum

I think you need to set the attribute value instead of the id, this is the code I have in my form and this works.


<?php 

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

			array(

				'model' => $model,

				'attribute' => 'birthday',

				'language' => 'nl',

				'options' => array(

					'showAnim' => 'fold',

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

					'defaultDate' => $model->birthday,

					'defaultDate' => '1990-01-01',

					'changeYear' => true,

					'changeMonth' => true,

					'yearRange' => '1900',

				),

		));

	?>

That seems to have worked however I couldn’t include the ‘id’ or ‘name’ attributes. It worked but now I have another issue I need to work out.

Thanks,

-Nazum