beforeSave(){
if($this->data['date_field']=='0000-00-00')
unset($this->data['date_field']);this set NULL for data_field On 12 Lis, 14:38, Braindead <[email protected]> wrote: > Hi all, > > In my form I have a date field. I use the form helper to generate a > year, month and day field for the date. > > $form->input('date_field', array('type' => 'date'); > > Now I was asked to change the field, so that the users can enter the > date into a text field using yyyy-mm-dd as format. > > $form->input('date_field', array('type' => 'text'); > > Actually this works as long as a date is entered. If the field is left > blank, Cake saves 0000-00-00 instead of NULL, although the field in > the database is set to accept NULL values. > > Is there a build in feature to force Cake to save NULL instead of > '' (empty)? Or do I have to process the date field in the beforeSave > event? > > Thanks, > Markus -- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cake-php?hl=.
