Issues

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

Issue Type: Improvement Created: 2009-05-12T09:25:09.000+0000 Last Updated: 2012-05-29T20:43:09.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

Reporter: Ian Lewis (electricowl) Assignee: Frank Brückner (frosch) Tags: - Zend_View

  • FixForZF1.12
  • zf-crteam-priority

Related issues: - ZF-7847

Attachments: - FormCheckbox.php.patch

Description

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']); } }

Comments

Posted by Wim Joris (oxidiser) on 2010-12-30T06:17:01.000+0000

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.

Posted by Emmanuel Bouton (goten4) on 2011-09-23T22:13:39.000+0000

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 !

Posted by Ian Lewis (electricowl) on 2012-02-16T16:35:46.000+0000

Has anything been done on this issue?

I hate modifying library code in my applications...

Posted by Frank Brückner (frosch) on 2012-05-04T15:49:42.000+0000

Patch and unit test added.

Posted by Rob Allen (rob) on 2012-05-29T20:43:09.000+0000

Fixed in SVN r24825.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts