Hi,
In my Users table I have a boolean field named "active" and defined as
a tinyint(1).

The Edit screen nicely shows this field as a checkbox. This seems to
be some magic of:
$form->input('active')

Now, this field is simply displayed as a 1 or a 0 in the View or List
screens. The scaffolded code reads:
echo $user['User']['active']

I would like to have the field displayed here as a checkbox also. I
tried a few things, and they are puzzling me:

echo $form->checkbox('User.active', array('checked' => $user['User']
['active'] ))
I would expect this to work, but the checkbox is always unchecked,
regardless of the value of the active field.

Next attempt:
echo $form->checkbox('User.active', array('checked' => $user['User']
['active']==1 ))
Although this seems equivalent to the previous one, it does work.
Displays the field correctly. But you can edit the field in the View
screen (of course it will not save).

So making it display as a disabled checkbox:
echo $form->checkbox('User.active', array('checked' => $user['User']
['active']==1  ,'disabled' => 'disabled'))

OK, this works. Thanks for your attention so far. Now my question:
This is a lot of code for each checkbox. Is there a shorter or more
elegant way to achieve this?

Thanks,
Mike

PS: I am using the nightly build of 1.2 which I grabbed a few days
ago. So if you cannot find $form->checkbox you may need to grab a more
recent version.
PPS: If you want to suggest html->checkbox, it has been deprecated.


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