Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Form with xthml scripts (without using decorators)
    text
    copied!<p>(I follow <a href="http://www.nabble.com/Zend_Form-complex-forms-td16785924.html" rel="nofollow noreferrer">this post</a> to got the logic how to use Zend_Form without using decorators.)</p> <p>within the action I create Zend_Form object and assigned the form to the view before rendering it:</p> <pre><code>public function indexAction() { $form = new Zend_Form(); $form-&gt;setAction('process') -&gt;setMethod('post'); $username = $form-&gt;createElement('text','username'); $username-&gt;addValidator('alnum') -&gt;setRequired(true) -&gt;addFilter('StringtoLower'); $description = $form-&gt;createElement('textarea','description'); $description-&gt;addValidator('alnum') -&gt;setRequired(false) -&gt;addFilter('StringtoLower'); $submit = $form-&gt;createElement('submit','Submit'); $form-&gt;addElement($username); $form-&gt;addElement($description); $form-&gt;addElement($submit); $this-&gt;view-&gt;form = $form; $this-&gt;view-&gt;render('myForm/index.phtml'); //myForm is the actionController } </code></pre> <p>Then I add following code to it's view script (index.phtml)</p> <pre><code>&lt;form&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Username&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $this-&gt;form-&gt;getElement('username')-&gt;renderElement(); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label&gt;Description&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $this-&gt;form-&gt;getElement('description')-&gt;renderElement(); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $this-&gt;form-&gt;getElement('submit')-&gt;renderElement(); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>But it's get an error </p> <blockquote> <p>Message: Decorator by name Element does not exist</p> </blockquote> <p>I didn't use decorators,What is the problem of my code.</p> <p>This is the complete custom error message </p> <pre><code>Application error Exception information: Message: Decorator by name Element does not exist Stack trace: #0 [internal function]: Zend_Form_Element-&gt;__call('renderElement', Array) #1 C:\Program Files\Zend\Apache2\htdocs\Demo1\application\views\scripts\myForm\index.phtml(5): Zend_Form_Element_Text-&gt;renderElement() #2 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\View.php(108): include('C:\Program File...') #3 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\View\Abstract.php(833): Zend_View-&gt;_run('C:\Program File...') #4 C:\Program Files\Zend\Apache2\htdocs\Demo1\application\controllers\MyFormController.php(38): Zend_View_Abstract-&gt;render('myForm/index.p...') #5 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\Controller\Action.php(513): myFormController-&gt;indexAction() #6 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action-&gt;dispatch('indexAction') #7 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\Controller\Front.php(946): Zend_Controller_Dispatcher_Standard-&gt;dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #8 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\Application\Bootstrap\Bootstrap.php(77): Zend_Controller_Front-&gt;dispatch() #9 C:\Program Files\Zend\Apache2\htdocs\Demo1\library\Zend\Application.php(335): Zend_Application_Bootstrap_Bootstrap-&gt;run() #10 C:\Program Files\Zend\Apache2\htdocs\Demo1\public\index.php(27): Zend_Application-&gt;run() #11 {main} </code></pre> <p>How I solve this problem without using decorators</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