Unable To Load Date With Cjuidatepicker

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


'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'})}", 

Change to:


 'afterAjaxUpdate'=>"function(){jQuery('#DOB').datepicker({'dateFormat': 'yy-mm-dd'});jQuery('#Start_Date').datepicker({'dateFormat': 'yy-mm-dd'});jQuery('#End_Date').datepicker({'dateFormat': 'yy-mm-dd'})}", 

You have to use some extension, like datetimepicker: http://www.yiiframework.com/extension/datetimepicker/

Hi Junior Member,

Thanks your solution worked for me. It is working fine as expected.

Thanks a lot.

Hi Master Member,

I went through the link provided by you, but i am unable to understand how to use it.

I have extracted the file in extensions\timepicker\assets\jquery-ui-timepicker-addon.js folder and copied the code to _form view.




<?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');

    $this->widget('CJuiDateTimePicker',array(

        'model'=>$model, //Model object

        'attribute'=>'nextupdate', //attribute name

                'mode'=>'datetime' //use "time","date" or "datetime" (default)

        'options'=>array() // jquery plugin options

    ));

?>




after adding the code when checked it is throwing error.

Kindly assist me.

Thanks in advance.

Regards

Sanjay

Hi,

I am unable to resolve it can someone please help me.

Hi,

Kindly ignore the request, I have solved it myself.

Thanks for your support