This repository was archived by the owner on May 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 810
custom decorator #713
Copy link
Copy link
Open
Labels
Description
Hello, i extend Zend_Form and do in _construct()
$this->addElementPrefixPath('Example_Form_Decorator', 'Example/Form/Decorator/, 'DECORATOR');
$this->addDisplayGroupPrefixPath('Example_Form_Decorator', 'Example/Form/Decorator/', 'DECORATOR');
And in form:
$permissions = new Zend_Form_Element_Text('xxxx');
$permissions->setLabel('xxxx')
->addDecorator('Accordion'); // Custom decorator.
This work well in 1.11.11 but gives a "not existing decorator exception in 1.12.18
The problem is you changed Zend_Form::addElement()
Now you call getDecorators() before you do addPrefixPaths()
Here is a fix:
diff -Naur org/Zend/Form.php fixed/Zend/Form.php
--- org/Zend/Form.php 2016-07-14 15:27:04.060777649 +0200
+++ fixed/Zend/Form.php 2016-07-14 15:27:48.000000000 +0200
@@ -1048,18 +1048,20 @@
$prefixPaths = array_merge($prefixPaths, $this->_elementPrefixPaths);
}
- if (is_array($this->_elementDecorators)
- && 0 == count($element->getDecorators())
- ) {
- $element->setDecorators($this->_elementDecorators);
- }
-
if (null === $name) {
$name = $element->getName();
}
$this->_elements[$name] = $element;
$this->_elements[$name]->addPrefixPaths($prefixPaths);
+
+
+ if (is_array($this->_elementDecorators)
+ && 0 == count($this->_elements[$name]->getDecorators())
+ ) {
+ $this->_elements[$name]->setDecorators($this->_elementDecorators);
+ }
+
} else {
require_once 'Zend/Form/Exception.php';
throw new Zend_Form_Exception(
Reactions are currently unavailable