Hi all,
I am not sure if my question is isoteric but I can’t seem to get it working.
I have a date of birth field in my registration form. it is represented as:
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'dob'); ?>
<?php echo CHtml::activeTextField($model,'dob',Users::model()->defaultDate())." - format: mm-dd-yyyy"; ?>
</div>
In my model I have declared the following function, which calls the default value:
public function defaultDate()
{
if($this->dob=="")
{
return array(
'value'=>'MM-DD-YYYY',
);
}elseif($this->dob!="" && $this->dob != 'MM-DD-YYYY')
{
return array(
'value'=>$this->dob,
);
}
}
When I first load the registration form I get a default value of MM-DD-YYYY in the text field. Then I change it to lets say 10-10-1984, which is absolutely valid date according to my rules. When I click on register the application is being sent to the create action. If there are any outstanding errors I am being returend to the form again and surprisingly I don’t see my last date as the value but I see MM-DD-YYYY in the date of birth again.
Can you please help me clear out where am I making a mistake in my code?
Thanks!