Details
Description
Reproduce code:
$captcha = new Zend_Form_Element_Captcha('captcha', array(
'captcha' => array(
'captcha' => 'Image',
'wordLen' => 6,
'timeout' => 300,
'font' => Zend_Registry::get('siteRootDir') . '/application/sketchh.ttf',
)
));
$captcha->setDecorators(array(
//captcha decorator are placed at the begining of the array by default by 'render' method
array('decorator' => array('foo' => 'HtmlTag'), 'options' => array('tag' => 'span')),
array('decorator' => array('bar' => 'HtmlTag'), 'options' => array('tag' => 'div')),
));
what we expect is to have something like this:
<div><span>CAPTCHA</span></div>
but the result is this:
<div>CAPTCHA</div>
The problem is that the aliases of the decorators (foo and bar) are lost while the 'render' method of Zend_Form_Element_Captcha adds its own decorators at the begining of the decorators array. This is done by "array_unshift" and then call to "setDecorators" but "setDecorators" in fact removes all current decorators and adds the new one with "addDecorators". There we have
foreach ($decorators as $decoratorInfo)
and here in fact the alias of the decorator is lost (in this case the alias is the index of the decorator in the array)
Looks like defect in Zend_Form_Element::addDecorators not in Captcha. Matthew, could you take a look?