ZF-10065: Radio Element adds a Label decorator automatically
Description
When using radio element with a custom decorator (for example view script decorator) and you do not set the disableLoadDefaultDecorators flag to true the element adds a label decorator to the element.
This is not consistent with how other elements work, and in my case it causes the element to render an extra label decorator.
Commit 22151 in the Subversion changed the way Zend_Form_Element_Radio loads decorators.
What has changed can be seen here: http://framework.zend.com/code/browse/… and the commit message refers to the issue ZF-9682.
Comments
Posted by Boyan Krastev (masterbo) on 2010-08-10T01:44:38.000+0000
Adding a simple check if there are decorators set will fix the issue.
Also the @return type is wrong. Should be Zend_Form_Element_Radio.
Posted by Simon Corless (sico) on 2010-12-08T14:21:56.000+0000
Why not check for a label decorator and if there is one set the disableFor attribute to true. If there isn't a label then add the default one as normal and set the disableFor.
public function loadDefaultDecorators() { parent::loadDefaultDecorators();
The parent::loadDefaultDecorators(); takes care of the first if() in the new method itself. Then you just check for a label and disable the for option.