Generate opening <form> tag using a Zend Framework view helper (Zend_View_Helper_Form)

Sometimes you have to use Zend_Form in such a way that you’re manually laying out tags in a specific way for presentation or other purposes, and it’s useful to be able to automatically generate the opening <form> tag with the correct attributes.

In your view, do the following:

<?php echo $this->form('myForm', $this->myForm->getAttribs()); ?>

where you’ve previously added an instance of myForm to the view in your controller. The form tag will be generated with the attributes you’ve set on the form object (eg method, action, etc.) Then you can simply close the form tag after manually laying out whatever elements you need to.

Leave a Reply