Hi,
I am having 3 Date field column in my table. I am using CJuiDatePicker to pick date. It is working in CGridView for all the 3 field but only for the first search and again to load the date picker it is working only for 3rd field (End_Date). i want it to work for other two fields also.
I have done as per below for all my fields DOB, Start_Date & End_Date & .
Below snip from _form.php
<div class="row">
<?php echo $form->labelEx($model,'Start_Date'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker',
array( 'attribute'=>'Start_Date',
'model'=>$model,
'options' => array(
'mode'=>'focus',
'dateFormat'=>'d MM, yy',
'showAnim' => 'slideDown',
),
'htmlOptions'=>array('size'=>30,'class'=>'date'),
)
);
?>
<?php echo $form->error($model,'Start_Date'); ?>
</div>
Below snip from Master.php
protected function beforeSave()
{
$this->DOB=date('Y-m-d', strtotime(str_replace(",", "", $this->DOB)));
$this->Start_Date=date('Y-m-d', strtotime(str_replace(",", "", $this->Start_Date)));
$this->End_Date=date('Y-m-d', strtotime(str_replace(",", "", $this->End_Date)));
return TRUE;
}
Below snip from admin.php
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'master-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'afterAjaxUpdate'=>"function(){jQuery('#DOB').datepicker({'dateFormat': 'yy-mm-dd'})}",
'afterAjaxUpdate'=>"function(){jQuery('#Start_Date').datepicker({'dateFormat': 'yy-mm-dd'})}",
'afterAjaxUpdate'=>"function(){jQuery('#End_Date').datepicker({'dateFormat': 'yy-mm-dd'})}",
'columns'=>array(
........
array('name' => 'DOB', 'type' => 'raw', 'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'DOB', 'htmlOptions' => array('id' => 'DOB'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)),
array('name' => 'Start_Date', 'type' => 'raw', 'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'Start_Date', 'htmlOptions' => array('id' => 'Start_Date'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)),
array('name' => 'End_Date', 'type' => 'raw', 'filter'=>$this->widget('zii.widgets.jui.CJuiDatepicker', array('model'=>$model, 'attribute'=>'End_Date', 'htmlOptions' => array('id' => 'End_Date'), 'options' => array('dateFormat' => 'yy-mm-dd')), true)),
I am also having a field in table which is having date and time but with CJuiDatePicker i am getting only date not time, please help me to get time also in date picker.
I am using yii-1.1.12 version.
Thanks in advance.
Regards
Sanjay