Monday, December 1, 2008

select empty needs to save default value

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: