Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can write your own Decorator similar to:</p> <pre><code>class My_Form_Decorator_ErrorsHtmlTag extends Zend_Form_Decorator_Label { protected $_placement = 'APPEND'; public function render($content) { $element = $this-&gt;getElement(); $view = $element-&gt;getView(); if (null === $view) { return $content; } $separator = $this-&gt;getSeparator(); $placement = $this-&gt;getPlacement(); $tag = $this-&gt;getTag(); $tagClass = $this-&gt;getTagClass(); $id = $element-&gt;getId(); $errors = $element-&gt;getMessages(); if (!empty($errors)) { $errors = $view-&gt;formErrors($errors, $this-&gt;getOptions()); } else { $errors = ''; } if (null !== $tag) { $decorator = new Zend_Form_Decorator_HtmlTag(); if (null !== $tagClass) { $decorator-&gt;setOptions(array( 'tag' =&gt; $tag, 'id' =&gt; $id . '-errors', 'class' =&gt; $tagClass)); } else { $decorator-&gt;setOptions(array( 'tag' =&gt; $tag, 'id' =&gt; $id . '-errors')); } $errors = $decorator-&gt;render($errors); } switch ($placement) { case self::APPEND: return $content . $separator . $errors; case self::PREPEND: return $errors . $separator . $content; } } } </code></pre> <p>and then use it as (in class derived from <code>Zend_Form</code>):</p> <pre><code>$this-&gt;addPrefixPath('My_Form_Decorator', 'My/Form/Decorator/', 'decorator'); $element-&gt;setDecorators(array( 'ViewHelper', array(array('td' =&gt; 'HtmlTag'), array('tag' =&gt; 'td')), array('Label', array('tag' =&gt; 'td')), array('ErrorsHtmlTag', array('tag' =&gt; 'td')), array(array('tr' =&gt; 'HtmlTag'), array('tag' =&gt; 'tr')))); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload