ZF-4191: Zend_View_Helper_FormRadio generates improper id attributes for certain values

Issue Type: Bug Created: 2008-09-04T12:34:03.000+0000 Last Updated: 2011-06-28T16:38:58.000+0000 Status: Resolved Fix version(s): - 1.11.8 (07/Jul/11)

Reporter: Vladimir Michailenko (mich) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Form

  • Zend_View

Related issues: Attachments: - 4191.diff


{quote} $form = new Zend_Form(); $form->addElement('radio', 'myName', array( 'value' => '-1', 'multiOptions' => array( 'inherit' => 'inherit', -1 => 'reset', 1 => 'allow', 0 => 'deny', ), )); $form->populate(array('myName' => 'inherit')); echo $form; {quote}

Generated xhtml:

{quote} inherit
deny {quote}

has two elements with same id "myName-1" (options "-1" and "1"). Also "0 => 'deny'" option is selected, but I have populated form with "'myName' => 'inherit'". Also "0 => 'deny'" option will be selected by default, but I set default "'value' => '-1'".


Posted by Joeri Sebrechts (jsebrech) on 2008-12-22T13:31:02.000+0000

Patch to fix the issue. The problem was that dashes were filtered from the id through the use of the alnum filter. In the patch a regex is used to allow both alphanumeric characters and dashes.

Posted by Simon Corless (sico) on 2010-12-09T00:29:38.000+0000

Is there any chance of getting this fixed or adding the patch to trunk?

Posted by Adam Lundrigan (adamlundrigan) on 2011-05-28T16:36:35.000+0000

Tidied suggested fix and added more thorough unit test

Posted by Adam Lundrigan (adamlundrigan) on 2011-05-28T16:47:29.000+0000

Fixed in trunk r24059

Posted by Adam Lundrigan (adamlundrigan) on 2011-06-24T12:15:49.000+0000

I've hesitated to merge this into release as it may cause a BC break for those who reference their Zend_Form elements by id from a view script. Thoughts?

Posted by Kim Blomqvist (kblomqvist) on 2011-06-24T12:43:02.000+0000

I would patch this.

Posted by Adam Lundrigan (adamlundrigan) on 2011-06-28T16:37:51.000+0000

Merged to release-1.11 in r24160

Have you found an issue?

See the Overview section for more details.


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

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