I'm developing my first CakePHP and this is my first post here, so
bare with me. Thanks in advance for any help.

I have a form with several yes/no questions. I chose to store these in
the database as tinyint(1) (using mysql), since they are fundamentally
boolean values. By default, CakePHP renders these fields as
checkboxes. I chose to override this functionality and display these
questions with two yes/no radio buttons, so "no" and "nothing
selected" can be distinguished. This setup is working great if one of
the two options is selected.

I'm having problems getting Cake to do the right thing, however, when
neither radio button is selected. In this case, I would like to store
NULL in the database, to represent the fact that neither option was
selected. After posting, $this->data correctly shows empty values for
the fields with neither option selected. But Cake is automatically
writing "0" to all the tinyint fields that aren't explicitly set to
"1". This includes all the fields with no option selected.

OK, so my question is, is there any way to stop cake from writing "0"
to a tinyint field by default, if no value is set in $this->data?

If this isn't possible, I think I can probably change all these
tinyint fields into enums with "yes" and "no" as options, or something
along those lines. If possible, though, I'd like to stick to tinyints
since they're more appropriate for the data.

Thanks for the help!

--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to