Вы можете написать свой собственный декоратор, похожий на:
class My_Form_Decorator_ErrorsHtmlTag
extends Zend_Form_Decorator_Label
{
protected $_placement = 'APPEND';
public function render($content) {
$element = $this->getElement();
$view = $element->getView();
if (null === $view) {
return $content;
}
$separator = $this->getSeparator();
$placement = $this->getPlacement();
$tag = $this->getTag();
$tagClass = $this->getTagClass();
$id = $element->getId();
$errors = $element->getMessages();
if (!empty($errors)) {
$errors = $view->formErrors($errors, $this->getOptions());
} else {
$errors = '';
}
if (null !== $tag) {
$decorator = new Zend_Form_Decorator_HtmlTag();
if (null !== $tagClass) {
$decorator->setOptions(array(
'tag' => $tag,
'id' => $id . '-errors',
'class' => $tagClass));
} else {
$decorator->setOptions(array(
'tag' => $tag,
'id' => $id . '-errors'));
}
$errors = $decorator->render($errors);
}
switch ($placement) {
case self::APPEND:
return $content . $separator . $errors;
case self::PREPEND:
return $errors . $separator . $content;
}
}
}
, а затем использовать его как (в классе, производном от Zend_Form
):
$this->addPrefixPath('My_Form_Decorator', 'My/Form/Decorator/', 'decorator');
$element->setDecorators(array(
'ViewHelper',
array(array('td' => 'HtmlTag'), array('tag' => 'td')),
array('Label', array('tag' => 'td')),
array('ErrorsHtmlTag', array('tag' => 'td')),
array(array('tr' => 'HtmlTag'), array('tag' => 'tr'))));