Yii: CActiveForm JUI – JQuery UI Inputs (CJuiDatePicker)
I found it pretty difficult to find a reference for how to integrate a jQuery UI date picker in with my CActiveForm view and model.
This is what I found to work correctly for datepicker, for the model field “dob_date”.
<div>
<?php echo $form->labelEx($model, 'dob_date'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => CHtml::activeName($model, 'dob_date'),
'value' => $model->attributes['dob_date'],
));
?>
<?php echo $form->error($model, 'dob_date'); ?>
</div>
You might need to wrap a function around $model->attributes['dob_date'] to output it as dd/mm/YYYY from a timestamp if that’s the type of field the model attribute represents
November 23rd, 2011 at 03:27
Here is an example of one I did just barely … and it works well
labelEx($model,’birthDate’,array(‘label’=>$label)); ?>
widget(‘zii.widgets.jui.CJuiDatePicker’,array(
‘model’=>$model,
‘attribute’=>’birthDate’,
// additional javascript options for the date picker plugin
‘options’=>array(
‘showAnim’=>’fold’,
‘dateFormat’=>’yy-mm-dd’,
‘changeYear’=>true,
‘changeMonth’=>true,
‘yearRange’=>’1940:2011′
),
)); ?>
error($model,’birthDate’); ?>
December 14th, 2011 at 16:00
thanks a million! that was very helpfull (especially since the yiiframework website is down at the moment)
Meg