Hi again!

I'm trying to use the FormHelper to make checkboxes for simple enum
data in my database. The values in the database are always stored as
'yes' or 'no'.

I can get the form to work just fine using dropdown select elements,
but I can't get it to work with checkboxes. The boxes are always
checked. I think the thing I haven't worked out is how to tell
FormHelper that I want 'no' to mean unchecked and 'yes' to mean
checked. I included the key/value pair of 'value' => 'yes' in the
array of options, but this doesn't seem to be helping.

I've looked at the code at 
http://api.cakephp.org/1.2/form_8php-source.html#l00672
, especially these lines:

00673         $value = 1;
00674         if (isset($options['value'])) {
00675             $value = $options['value'];
00676             unset($options['value']);
00677         }

...and these ones:

00695         if (isset($options['value']) && $value ==
$options['value']) {
00696             $options['checked'] = 'checked';
00697         } elseif (!empty($value)) {
00698             $options['value'] = $value;
00699         }

I'm not entirely sure, but it looks like specifying any value in the
options would cause the checkbox to be checked as a result, is this
right?

At any rate, does anyone know the correct way to tell FormHelper that
a 'yes' value being pulled out of the database should result in the
checkbox being checked, while a 'no' value should result in it being
unchecked?

Many thanks for your help again everyone,
Zoe.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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