Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Programmatic forms in the ZF only support the parameters type, name and options (not in the meaning of choices but of element settings, like required or label) for the form elements. It is assumed that multiple values will be set dynamically, e.g:</p> <pre><code>$formConfig = new Zend_Config_Xml('/path/to/form.xml'); $form = new Zend_Form($formConfig); $form-&gt;getElement('myselect')-&gt;setMultiOptions($arrayOfOptions); </code></pre> <p>Of course there's the possibility of actually setting the element options in the XML file using your own name convention (will be ignored by Zend_Form) and then load them from there instead of having the hardcoded or retrieved at runtime, for instance:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;form&gt; &lt;user&gt; &lt;example&gt; &lt;name&gt;mysampleform&lt;/name&gt; &lt;method&gt;post&lt;/method&gt; &lt;elements&gt; &lt;myselect&gt; &lt;type&gt;select&lt;/type&gt; &lt;name&gt;myselect&lt;/name&gt; &lt;multioptions&gt; &lt;!-- custom tag --&gt; &lt;option value="First"&gt;1&lt;/option&gt; &lt;option value="Second"&gt;2&lt;/option&gt; &lt;option value="Third"&gt;3&lt;/option&gt; &lt;/multioptions&gt; &lt;options&gt; &lt;label&gt;Choose an option:&lt;/label&gt; &lt;required&gt;true&lt;/required&gt; &lt;/options&gt; &lt;/myselect&gt; &lt;submit&gt; &lt;type&gt;submit&lt;/type&gt; &lt;options&gt; &lt;value&gt;Submit&lt;/value&gt; &lt;/options&gt; &lt;/submit&gt; &lt;/elements&gt; &lt;/example&gt; &lt;/user&gt; </code></pre> <p></p> <pre><code>$formConfig = new Zend_Config_Xml('/path/to/form.xml'); $form = new Zend_Form($formConfig); $form-&gt;getElement('myselect')-&gt;setMultiOptions( $formConfig-&gt;user-&gt;example-&gt;elements-&gt;myselect-&gt;multioptions-&gt;toArray() ); </code></pre> <p>Yet it doesn't seem to be more effective than just having those options stored somewhere else.</p>
 

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