ZF-2230: View helper for checkbox is not compatible with array
Description
Zend_View_Helper_FormCheckbox should NOT render hidden element with "0" value when the name of the checkbox is array-like variable such as
$this->formCheckbox('languages[]', ...
Because programmer usually needs submit only those items, which are checked and not fill the array with zeros
I vote to modify the code something like that
$is_array = substr($name, -2) == '[]'; if (!$is_array) { $xhtml .= $this->_hidden($name, $options[1]); }
Comments
Posted by Darby Felton (darby) on 2007-11-30T08:52:53.000+0000
Assigning to [~matthew] and marking to fix for 1.1.0 or next mini release.
Posted by Matthew Weier O'Phinney (matthew) on 2008-02-13T08:37:38.000+0000
Resolved in trunk. The 'options' argument now is no longer used; simply provide a true value to the 'checked' attribute, and the checkbox will be checked appropriately (a false value will leave it unchecked).