ZF-9682: Zend_Form_Element_Radio added with Zend_Form with added prefix paths does not load correct Label decorator (unit test + patch provided)



Let's say you have a Zend_Form. You add an elements prefix path (addElementsPrefixPath). Then, you build a Zend_Form_Element_Radio and add it.

You will see that your radio element does not have the good label decoractor. Why? Because any Zend_Form_Element loadDefaultDecorators in the construct. The loadDefaultDecorators of radio element do a "getDecorator('Label')" that will load the label decorator if not loaded. Since the addElement add the elements prefix path, it's too late because the label decorator is already loaded. Others element do a addDecorator - that won't load the decorator if it's a string, the decorator will be loaded in the render method.

The workaround is to specify the prefix paths in the constructor of the radio element, but then, first, you have to "duplicate" this add prefix path, second, it's not the same behavior than the others elements.

I will attach a patch for this and a test case a bit later.


Raphaël Dehousse


This is a patch for the tests suite of Zend_Form_Element_RadioTests

The test added should fail before the patch and should succeed with the patch.

Patch to apply in tag 1.10.3


Raphaël Dehousse

It affects also release 1.10.4

Fixed in trunk r22151 and merged into 1.10 release branch.