Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Be careful about Pradeep Sharma's solution (the answer he wrote himself and accepted below).</p> <p><strong>All the code code below is for ZF 1.12, and not ZF 2.0</strong></p> <p>In the bootstrap, Zend_Layout's MVC instance might not have been created yet. You should use <code>Zend_Layout::startMvc()</code> instead :</p> <pre><code>$view = Zend_Layout::startMvc()-&gt;getView() ; </code></pre> <p>And tbh I prefer executing this code in the preDispatch() function. New users of ZF might be interested in this :</p> <p>application/plugins/HeaderForm.php :</p> <pre><code>class Application_Plugin_HeaderForm extends Zend_Controller_Plugin_Abstract { public function preDispatch(Zend_Controller_Request_Abstract $request) { $view = Zend_Layout::startMvc()-&gt;getView() ; $view-&gt;headerForm = new Application_Form_HeaderForm() ; } } </code></pre> <p>Calling new <code>Application_Form_HeaderForm()</code> will autoload by default into <strong>application/forms/</strong> folder. You can also create the form directly into the plugin with <code>new Zend_Form()</code>, and <code>addElement()</code> etc. but it won't be reusable.</p> <p>Of course, you need to register this plugin in your bootstrap!</p> <p>application/Bootstrap.php :</p> <pre><code>class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initPlugin() { $front = Zend_Controller_Front::getInstance() ; $front-&gt;registerPlugin(new Application_Plugin_HeaderForm()) ; } } </code></pre> <p>Calling new <code>Application_Plugin_HeaderForm()</code> will autoload by default into <strong>application/plugins/</strong> folder</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