change text form to date form

hi there… i am very new to this yii framework…

i have some problems in making forms… i created forms in CRUD generator and the results are i have all text fill in forms… i want to change some text field forms to date pickers form but i’ve failed to do so…

here are my codings;

	<div class="row">

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

		<?php echo $form->textField($model,'PROG_ENDDATE'); ?> //i want to change this into date picker.. please help 

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


thank you in advance…

take a look at this page please:


So, you’ll end up with something like this:

	<div class="row">

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

                <?php echo DatePicker::widget(['model' => $model,'attribute' => 'PROG_ENDDATE',]); ?>

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


Um… sorry, if you’re on yii1.*, you should follow this link:


But I(and many others, you know) would strongly recomend you to start with yii2.

Thank you for your help…

now the problem is, when i save the date, it does not appear in my view… it says ‘not set’…

this is my coding

	<div class="row">

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

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




    // additional javascript options for the date picker plugin









the date i want does not appear in my database too…


I think the problem happens because the date’s format is different:

  • mysql: y-m-d;

  • CJuiDatePicker: dd-mm-yy;

This behavior can help you:

yes thank you… i have changed it :D thank you so much…

these are my codings in form.php

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


	//in _form.php

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

			'name' => 'PROG_ENDDATE',

			'attribute' => 'PROG_ENDDATE',


			'options'=> array(

			'showAnim' => 'fadeIn',

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

			'changeMonth' => true,

			'changeYear' => true,




and the other one at ../model/ folder

			//in model (e.g Program)

		public function beforeSave()


		$this->PROG_STARTDATE = date("Y-m-d", strtotime($this->PROG_STARTDATE));	

		$this->PROG_ENDDATE = date("Y-m-d", strtotime($this->PROG_ENDDATE));

		$this->PROG_SUBMITDATE = date("Y-m-d", strtotime($this->PROG_SUBMITDATE));

		return parent::beforeSave();