ZF-4191: Zend_View_Helper_FormRadio generates improper id attributes for certain values
Description
{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
reset
allow
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'".
Comments
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