I am in the process of editing my views to get a similar effect. If
you can wait a couple hours, I'll be back with an explanation.

But, to whet your appetite: controlling for '0000-00-00' is not that
different from controlling for null, seems to me. '0000-00-00' is the
'null value' for a date field. I have the problem of dates that can be
full, or just years, or just years and months, so I can't use a date
field at all, and have to validate my dates otherwise.

Basically, to edit the date fields as you like, you have to process
them before saving in the edit method, filling up the $this->data
['yourdatefield'] with a valid date from what you got. For example:
in the view, you have three inputs type='text' name='dateday',
name='datemonth', name='dateyear'
in the action, get the date fields and process them saving each value
to your $this->data['yourdatefield'] as a full 'yyyy-mm-dd' string.

Plus, you should also set the variable at the end of the edit action
doing the opposite action, so the dates to be modified should be
exploded and set to 'dateday', etc.

I hope I'm not making any mistaeks.

Cheers,

On 16 dic, 11:44, Sebastian Göttschkes <sebastian.goettsch...@mpx-
e.de> wrote:
> Hi,
>
> i got the following problem using cakePHP 1.2 RC3:
>
> My Model 'Employee' has a attribute called 'birthday' (datatype:
> DATE). In the add-view, I have the following code:
> <?= $form->input('birthday',array('type'=>'text'));?>
> If i left this field blank when adding an employee, this employee has
> the birthday '0000-00-00' saved in the database. I would rather like
> the birthday having the null-value, because 0000-00-00 is no valid
> birthday.
>
> Additionally, if I add a valid birthday, it is saved correctly. When
> editing the employee, I would like to get the birthday viewed in the
> format dd.mm.yyyy. How can I tell cake to view the birthday like this?
>
> I hope you guys can help me.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to