How does $form->checkbox() really work?
Permalink
Based on the documentation, I expected that this would render a checked checkbox:
But this does not render a checkbox in a checked state. Instead changing the "value" to false caused the checkbox to be checked by default - like so:
The problem with this is that the value being rendered is now "false" so testing for this in the controller is more difficult. Am I missing something? The only way I could get this to work was to do the following:
Thanks!
$form->checkbox('dedup_addresses',true,true);
But this does not render a checkbox in a checked state. Instead changing the "value" to false caused the checkbox to be checked by default - like so:
$form->checkbox('dedup_addresses',false,true);
The problem with this is that the value being rendered is now "false" so testing for this in the controller is more difficult. Am I missing something? The only way I could get this to work was to do the following:
$form->checkbox('dedup_addresses',true,true,array('checked'=>'checked'));
Thanks!
My usual code gives a checkbox a string value, such as:
Where $dedup_addresses is the value provided from the controller (ie saved last time).
So in essence: