ZF-8622: Zend_Form_Element::setDecorators() can't set what getDecorators() returned


If I do:

$dec = $this->getDecorators(); $this->setDecorators($dec); $dec2 = $this->getDecorators();

var_dump($dec); echo "--------"; var_dump($dec2);

I loose a decorator (see attachment)


created controller action testcase

anyone here?

Please note that it's been holidays for a lot of people the past few weeks, meaning that they either did not work, or worked less. Besides that, unfortunately this issue isn't the only issue out there :'(

If you don't feel like waiting, you could create a patch, preferably with unittests. By doing so, you greatly improve the chances of getting it fixed soon.

Sorry but how could I create a patch for this if I didn't even get a response like "I confirm it's a bug"?

@Francesco: create a reproduce case, and document expected and actual results. Ideally, capture the reproduce case as a unit test.

Mattew: I created a reproduce case. It's attached as 'testcase.php'.

What I need to do is get element decorators and set what i got. The wrong result is that if you get decorators again, you read something different. Actual results are in 'decorators.html', where I dumped what I expected and what I got.

=           } elseif ($decoratorInfo instanceof Zend_Form_Decorator_Interface) {
-               $this->addDecorator($decoratorInfo);
+               $this->addDecorator(array(key($decorators) => $decoratorInfo));
+               next($decorators);

But my last solution could lead to problems when calling addDecorators multiple times with nonassociative arrays, so

=           } elseif ($decoratorInfo instanceof Zend_Form_Decorator_Interface) {
+               if (!is_numeric($name = key($decorators)) {
+                   $this->addDecorator(array($name => $decoratorInfo));
+               } else {
=                   $this->addDecorator($decoratorInfo);
+               }
+               next($decorators);

Fixed in r22464 and merged into 1.10 release branch