Well, when you provide the htmlAttributes parameter with 'value'=>'1',
you're giving the value that should be submitted if the checkbox is
ticked. So, if you had:
$html->checkbox('User/acceptEULA', null, array('value'=>'Sure do'));
and they ticked the checkbox, your data would be
User['acceptEULA'] = 'Sure do'
To set a checkbox into a checked state, you could provide the
htmlAttributes parameter with the appropriate HTML value to tick a
checkbox, which is 'checked'=>'checked'.
However, you probably don't want the checkbox to be ALWAYS ticked like
this, rather display whatever value the User['ave'] attribute already
has stored. All of the form element functions provided by the HTML
helper look at the $this->data value set by the controller for the
prepopulated values (some of them have a parameter for the current
value, but it doesn't look like checkbox has this, apart from the
'checked'=>'checked' just mentioned).
So, the reason RosSoft's solution works, is because you are setting the
data value of User['ave'] to 1, then defining on your checkbox that the
checked value of the checkbox is 1 ('value'=>'1'). The HTML helper is
smart enough to automatically look for this, find that the values
match, and tick the checkbox.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---