Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's probably a cleaner way to do this, but here's my custom decorator to accomplish this (<em>Note:</em> you need to extend the Zend_Form_Decorator_Label class):</p> <pre><code>/** * Class for HTML tag surrounding label * @var string */ protected $_tagClass; /** * Set HTML tag's class * * @param string $tag * @return Zend_Form_Decorator_Label */ public function setTagClass($tagClass) { if (empty($tagClass)) { $this-&gt;_tagClass = null; } else { $this-&gt;_tagClass = (string) $tagClass; } $this-&gt;removeOption('tagClass'); return $this; } /** * Get HTML tag's class, if any * * @return void */ public function getTagClass() { if (null === $this-&gt;_tagClass) { $tagClass = $this-&gt;getOption('tagClass'); if (null !== $tagClass) { $this-&gt;removeOption('tagClass'); $this-&gt;setTagClass($tagClass); } return $tagClass; } return $this-&gt;_tagClass; } /** * Render a label * * @param string $content * @return string */ public function render($content) { $element = $this-&gt;getElement(); $view = $element-&gt;getView(); if (null === $view) { return $content; } $label = $this-&gt;getLabel(); $separator = $this-&gt;getSeparator(); $placement = $this-&gt;getPlacement(); $tag = $this-&gt;getTag(); $tagClass = $this-&gt;getTagClass(); $id = $this-&gt;getId(); $class = $this-&gt;getClass(); $options = $this-&gt;getOptions(); if (empty($label) &amp;&amp; empty($tag)) { return $content; } if (!empty($label)) { $options['class'] = $class; $label = $view-&gt;formLabel($element-&gt;getFullyQualifiedName(), trim($label), $options); } else { $label = '&amp;#160;'; } if (null !== $tag) { require_once 'Zend/Form/Decorator/HtmlTag.php'; $decorator = new Zend_Form_Decorator_HtmlTag(); $decorator-&gt;setOptions(array('tag' =&gt; $tag, 'id' =&gt; $id . '-label', 'class' =&gt; $tagClass)); $label = $decorator-&gt;render($label); } switch ($placement) { case self::APPEND: return $content . $separator . $label; case self::PREPEND: return $label . $separator . $content; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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