I’m actually looking for a nice way to have generic decorators for all my forms elements but at the same time being able to change some decorators of some elements very specifically.
Say i want all my elements to have new generic decorators. I would do that in the addElement method of my parent generic form class. For example in My_Form class extending Zend_Form wich would be extended by a My_Form_User containing actual elements declarations, i would have something like :
public function addElement($element, $name = null, $options = null)
{
parent::addElement($element, $name, $options);
if (! is_object($element)) {
$element = $this -> getElement($name);
}
if (is_object($element))
{
$element -> clearDecorators();
$element -> addDecorators($this -> elementDecorators);
}
return $this;
}
Now, i have very specific needs on some elements of some forms. So i set these decorators when i create the element (in My_Form_User class) but, of course, when i add them to the form with addElement, i can’t find of a way to check if 1 decorator (ViewHelper or Description or Label…) has been modified so that i don’t erase it with the generic one.
Any idea ? Thanks !
It’s a bit short, but …
…maybe this helps already.