ZF-3026: Bug with checked attribute in FormCheckbox helper.
Description
The logic for 'checking' a checkbox does not fit with the documentation. The documentation states:
formCheckbox($name, $value, $attribs): Creates an element. If $value matches the "checked" value, the box will be checked for you.
However, if you use the logic:
<?=$this->FormCheckbox('FieldName', 'true', array('checked' => $this->GetParam('FieldName')))?>It won't check the field on postback.
I have amended my code inside the Zend helper to the following:
if (isset($attribs['checked']) && $attribs['checked'] == $value) {
$checked = ' checked="checked"';
unset($attribs['checked']);
} else {
unset($attribs['checked']);
}
This has resolved the issue for me. Hope this is helpful.
Comments
Posted by Wil Sinclair (wil) on 2008-04-18T16:03:38.000+0000
Please evaluate and categorize/assign as necessary.
Posted by Matthew Weier O'Phinney (matthew) on 2008-04-22T10:50:48.000+0000
Scheduling for next mini release.
Posted by Matthew Weier O'Phinney (matthew) on 2008-05-02T12:15:49.000+0000
Resolved with ZF-3149