ZF-6624: CLONE -Improvement for Zend_View -> Make hidden field optional


Zend_View_Helper_FormCheckbox automatically adds a hidden field preceding a checkbox as long as it does not have the form name[].

This is not desirable as a default as there are many situations where it will get in the way and cause issues with web applications. Particualrly those using JavaScript.

I suggest adding an attribute such as: 'useHiddenField' => true which will enable the field for those who need it.

if (isset($attribs['useHiddenField']) && $attribs['useHiddenField']) { if (!strstr($name, '[]')) { $xhtml = $this->_hidden($name, $checkedOptions['unCheckedValue']); } }


I had a problem where some browsers put the order wrong so the input element containing the actual value got ignored and the value of the hidden field was passed through. Not exactly the wanted behavior if you ask me.

I needed to extend the Zend_View_Helper_FormCheckbox class and overload the formCheckbox() method to remove the hidden field to fix this problem.

I would appreciate this behavior being optional as well.

I'd appreciate too such an option, because I'm using jquerymobile in my app and it enhances certain native form controls into rich touch-friendly components (especially checkboxes). I don't know exactly what is done by jquerymobile but when this behavior is enabled, the checkbox always returns 0. When I disable jquerymobile, it works perfectly !

Has anything been done on this issue?

I hate modifying library code in my applications...

Patch and unit test added.

Fixed in SVN r24825.