ZF-4932: Custom Decorators on a zend form element get modified if you render the element twice
I have a form that uses the Zend_Dojo_Form_Element_RadioButton element type. I have created my own decorator for this element and am applying it using the following code:
$element->setDecorators( array( 'DijitElement', array( array( 'dataStart' => 'HtmlTag'), array( 'tag' => 'th', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND) ), array( array( 'dataEnd' => 'HtmlTag'), array( 'tag' => 'td', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND) ), array( array( 'row' => 'HtmlTag'), array( 'tag' => 'tr') ), ) );
This decorator successfully creates a row for the table containing the form elements. During development however, I was rendering the element to a variable at the point in the code where it was created, so that I could see the output whilst debugging my code. I was then later rendering the form in the view in order to display the entire form on the web page, which resulted in this element being rendered a 2nd time.
The second time that the element was being rendered, the code that loads the decorator did not recognise that the decorator has already been loaded, and consequently attempted to load the decorator again, wiping out my decorator options, specifically the openOnly option.
I believe that the code should instead identify if the decorator has been loaded already before trying to re-load it.
This definately affects 1.6.2 - not sure about others as I havent used them.