Hi Guys,
I am getting into Yii and using it for a small project. I am using CJuiDatePicker for a date field. In the database the field is defined as a DATE (MYSQL btw). I have the following code in my view:
<div class="row">
<?php echo $form->labelEx($model,'ProbDate'); ?>
<?php /* echo $form->textField($model,'ProbDate',array('size'=>60,'maxlength'=>255)); */?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'attribute' => 'ProbDate',
'value' => $model->ProbDate,
'model' => $model,
'options'=>array(
'showAnim'=>'slideDown',
'showButtonPanel'=> 'true',
//'dateFormat'=>'yyyy-mm-dd', // optional Date formatting
),
'htmlOptions'=>array(
'style'=>'height:10px;'
),
));
?>
<?php echo $form->error($model,'ProbDate'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'ProbFName'); ?>
<?php echo $form->textField($model,'ProbFName',array('size'=>60,'maxlength'=>255)); ?>
<?php echo $form->error($model,'ProbFName'); ?>
</div>
And I have the following code segment in my model:
protected function beforeSave(){
$this->ProbDate = date('YYYY-MM-DD', strtotime( $this->ProbDate));
return parent::beforeSave();
}
No matter what I do to change this, I always get 0000-00-00 as a result. I have tried changing this value to something else physically in the database, but 0000-00-00 always gets written in when I submit an entry. I am using Yii Framework version 1.1.14 Any help would be appreciated. I can’t find any good resources for this and was hoping some of you experts have seen this before.