Zend Framework

Bug with checked attribute in FormCheckbox helper.

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.5.1
  • Fix Version/s: 1.5.2
  • Component/s: Zend_View
  • Labels:
    None
  • Fix Version Priority:
    Should Have

Description

The logic for 'checking' a checkbox does not fit with the documentation. The documentation states:

formCheckbox($name, $value, $attribs): Creates an <input type="checkbox" /> 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.

Issue Links

Activity

Hide
Wil Sinclair added a comment -

Please evaluate and categorize/assign as necessary.

Show
Wil Sinclair added a comment - Please evaluate and categorize/assign as necessary.
Hide
Matthew Weier O'Phinney added a comment -

Scheduling for next mini release.

Show
Matthew Weier O'Phinney added a comment - Scheduling for next mini release.
Hide
Matthew Weier O'Phinney added a comment -

Resolved with ZF-3149

Show
Matthew Weier O'Phinney added a comment - Resolved with ZF-3149

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
30m
Original Estimate - 30 minutes
Remaining:
30m
Remaining Estimate - 30 minutes
Logged:
Not Specified
Time Spent - Not Specified