Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Full control over the output of a form without circumventing the Form Logic / filtering / validation <code>The View:</p> <pre><code>&lt;form action="&lt;?php echo $this-&gt;form-&gt;getAction(); ?&gt;" method="&lt;?php echo $this-&gt;form-&gt;getMethod(); ?&gt;"&gt; &lt;!-- Errors For question field--&gt; &lt;?php echo (NULL != ($errors = $this-&gt;form-&gt;getElement('question')-&gt;getMessages()) ? $this-&gt;formErrors($errors) : ''); ?&gt; &lt;!-- question field --&gt; &lt;?php echo $this-&gt;form-&gt;getElement('question')-&gt;renderViewHelper(); ?&gt; &lt;!-- Submit Field --&gt; &lt;?php echo $this-&gt;form-&gt;getElement('submit')-&gt;renderViewHelper(); ?&gt; &lt;/form&gt; </code></pre> <p>End</code></p> <p><code>The Form</p> <pre><code>&lt;?php class Form_Question extends Zend_Form { public function init() { $this-&gt;setMethod(self::METHOD_POST); $element = $this-&gt;createElement('text', 'question'); $element-&gt;setLabel('Question'); $element-&gt;setRequired(TRUE); $element-&gt;removeDecorator('DtDdWrapper'); $element-&gt;setAttrib('class', 'text'); $this-&gt;addElement($element); $element = $this-&gt;createElement('submit', 'submit'); $element-&gt;setLabel('Submit'); $element-&gt;setRequired(TRUE); $element-&gt;removeDecorator('DtDdWrapper'); $element-&gt;removeDecorator('label'); $this-&gt;addElement($element); } } </code></pre> <p>end form</code></p> <p><code>the controller action</p> <pre><code> public function questionAction() { $form = new Form_Question(); if($this-&gt;getRequest()-&gt;isPost()) { if($form-&gt;isValid($this-&gt;getRequest()-&gt;getPost())) { // Do stuff } else { $this-&gt;_helper-&gt;FlashMessenger(array('error' =&gt; "Errors! Correct the errors in the form below")); } } $this-&gt;view-&gt;assign('form', $form); } </code></pre> <p>end controller action</code></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