Cjuidatepicker Working For One Field, But Not In Another In Same Form

Hello Friends,

My problem is: In the same form, the exact code is working for date_assigned but not working for date_completed. I’ve attached a picture of the list view, and code snippets for my form and model below. Appreciate the help!

Form




<div class="row">

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

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

		'model'=>$model,                           

		'attribute'=>'date_assigned', // Attribute name

			)); ?>             

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

</div>


<div class="row">

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

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

		'model'=>$model,                                

		'attribute'=>'date_completed',

			)); ?>             

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

</div>

Model




public function beforeSave()

        {	

		//checking date_assigned

                if ($this->date_assigned == '') {

                        $this->date_assigned = new CDbExpression('NOW()');

					} 

				else{

                        $this->date_assigned=date('Y-m-d', strtotime($this->date_assigned));

					}

					

				//checking date_completed

		if ($this->date_completed == '') {

                        $this->date_completed = NULL;

					} 

				else {

                        $this->date_completed=date('Y-m-d', strtotime($this->date_completed));

					}


       return parent::beforeSave();

	  

	 }

Folks, I figured it out - my variable date_completed was not defined as ‘safe’.