Hi.
I have the following use case:
I have a form which I use to override default decorators, element
decorators, add prefixes...all forms in the app are extending it. The
problem occurs when I try to set decorators on some specific element in
concrete form like:
...)->addElement(
'text',
'price',
array(
'label' => 'Cena:',
'disableLoadDefaultDecorators' => true,
'decorators' => array(
'viewHelper',
array('Label', array('class' =>
'someclass')),
)
)
)...
element never gets those decorators because
Zend_Form::setElementDecorators() does not care about
'disableLoadDefaultDecorators' attribute of element.
/**
* Set all element decorators as specified
*
* @param array $decorators
* @param array|null $elements Specific elements to decorate or exclude
from decoration
* @param bool $include Whether $elements is an inclusion or exclusion list
* @return Zend_Form
*/
public function setElementDecorators(array $decorators, array $elements =
null, $include = true)
{
if (is_array($elements)) {
if ($include) {
$elementObjs = array();
foreach ($elements as $name) {
if (null !== ($element =
$this->getElement($name))) {
$elementObjs[] = $element;
}
}
} else {
$elementObjs = $this->getElements();
foreach ($elements as $name) {
if (array_key_exists($name, $elementObjs)) {
unset($elementObjs[$name]);
}
}
}
} else {
$elementObjs = $this->getElements();
}
foreach ($elementObjs as $element) {
$element->setDecorators($decorators);
}
$this->_elementDecorators = $decorators;
return $this;
}
maybe this method needs an update, where disableLoadDefaultDecorators can be
checked and element excluded.
What do you think?
Or I can go with overriding setElementDecorators :P
Regards,
Saša Stamenković.
--
View this message in context:
http://n4.nabble.com/Zend-Form-suggestion-about-setElementDecorators-tp989752p989752.html
Sent from the Zend Framework mailing list archive at Nabble.com.