Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use ViewScript Decorator to do this</p> <p><a href="http://framework.zend.com/manual/en/zend.form.standardDecorators.html#zend.form.standardDecorators.viewScript" rel="nofollow">http://framework.zend.com/manual/en/zend.form.standardDecorators.html#zend.form.standardDecorators.viewScript</a></p> <p><strong>An Example</strong></p> <pre><code>class MyForm extends Zend_Form { public function init() { $this-&gt;addElement('checkbox', 'elementName', array( 'multiOptions' =&gt; array( 'level1' =&gt; array( 'Level 1 Option 1', 'Level 1 Option 2', ), 'level2' =&gt; array( 'Level 2 Option 1', 'Level 2 Option 2', ), ), 'label' =&gt; 'Element Label', 'decorators' =&gt; array( array('ViewScript', array( 'viewScript' =&gt; '_element.phtml', 'class' =&gt; 'form element') ) ) )); } } </code></pre> <p>Create _element.phtml in your view script directory.</p> <pre><code>&lt;div class="&lt;?php echo $this-&gt;class ?&gt;"&gt; &lt;?php echo $this-&gt;formLabel($this-&gt;element-&gt;getName(), $this-&gt;element-&gt;getLabel()) ?&gt; &lt;?php $options = $this-&gt;element-&gt;getAttribs(); ?&gt; &lt;?php if(isset($options['multiOptions']) &amp;&amp; is_array($options['multiOptions'])): ?&gt; &lt;ul&gt; &lt;?php foreach($options['multiOptions'] as $level =&gt; $levelOptions): ?&gt; &lt;li&gt; &lt;span&gt;&lt;?php echo $level; ?&gt;&lt;/span&gt; &lt;?php if(is_array($levelOptions)): ?&gt; &lt;ul&gt; &lt;?php foreach($levelOptions as $key =&gt; $value): ?&gt; &lt;li&gt; &lt;?php echo $this-&gt;{$this-&gt;element-&gt;helper}( $this-&gt;element-&gt;getName() . '[' . $key . ']', $this-&gt;element-&gt;getValue(), $options['options'] ) ?&gt;&lt;label&gt;&lt;?php echo $value; ?&gt;&lt;/label&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; &lt;?php echo $this-&gt;formErrors($this-&gt;element-&gt;getMessages()) ?&gt; &lt;div class="hint"&gt;&lt;?php echo $this-&gt;element-&gt;getDescription() ?&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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