ZF-3026: Bug with checked attribute in FormCheckbox helper.


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"';
    } else {

This has resolved the issue for me. Hope this is helpful.


Please evaluate and categorize/assign as necessary.

Scheduling for next mini release.

Resolved with ZF-3149