$score = new Zend_Form_Element_Radio('score');
$score->setRequired(true)
->setSeparator('')
->setMultiOptions(array(1 =>'Positive', -1 =>'Negative'))
->setDecorators(array('ViewHelper'));
Renders as
<label for="score-1">
<input name="score" id="score-1" value="1" checked="checked" type="radio">Positive
</label>
<label for="score-1">
<input name="score" id="score-1" value="-1" type="radio">Negative
</label>
Is the fact that it’s using the same ID for the inputs and labels normal behavior or a bug?
How can I correct this?
I can’t change the values as technically they are required to be that way
The real problem this causes is that when you click the negative the positive gets selected instead!
Thanks
Looks like the standard
ViewHelperdecorator for a radio control uses aFormRadioview-helper. When this view helper creates the id it uses on the <input> element and the <label> element, it first applies the standardAlNumfilter, which is filtering out your minus sign.So, it looks to me that instead of using the standard
ViewRendererdecorator, you will have to create a custom decorator that calls your own customFormRadioview helper.You might be able to avoid creating your own decorators and view helpers by creating your own custom
AlNumfilter that allows those minus signs. The trick is to set that path only for this single use so that you;ll be able to use the normalAlnumfilter for other elements.Alternatively, you could probably trick the
ViewHelperinto using a customFormRadiohelper by adding a helper path on the view object so that it loads your custom view helper instead of the standard one.Just some ideas.