Monday, December 1, 2008

Re: select empty needs to save default value

Hi Zoltan,
I am not too sure but what i can suggest is that
before saving your records chk if that field is blank

then give its value as $this->data['model name']]['field name']=0;

use this just before save.

Hope this might help

Best regards,
Deepesh

On Dec 2, 11:44 am, Zoltan <zed...@gmail.com> wrote:
> Sorry about the cryptic subject line...
>
> I have a few fields like category_id_1, category_id_2 and they're set
> up in mysql to be not Null and with a default value of 0.
>
> Now on the controller/view side I have something like:
> $form->input( 'Venue.category_id_1', array( 'empty' => true, 'options'
> => $categories ) );
>
> Now the problem is, if the blank option is set Cake tries to save a
> null to the field causing a mySQL error.
>
> How do I get it so that, if nothing is picked, instead of trying to
> save a blank to the field it uses the mySQL default value field?
>
> Zoltan
>
> www.yyztech.ca
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: