title: Zend Form SetAction Using Named Routes
body: <p>I have a form that I am trying to set the action for. I want to declare the action inside my form file (which extends Zend_Form) instead of in a controller or view, using a route I have created in my bootstrap.
  Usually when I want to use a route I do something like</p>
  
  <pre><code>$this-&gt;url(array(), 'route-name');
  </code></pre>
  
  <p>in the view, or</p>
  
  <pre><code>$this-&gt;_helper-&gt;url(array(), 'route-name');
  </code></pre>
  
  <p>in the controller.</p>
  
  <p>How do I call a route from within Zend_Form?</p>
  
  <hr>
  
  <p>edit:
  I have given up trying to load a route into zend_form. Perhaps in a future release there may be a function to easily do this?</p>
  
  <p>I have created a viewScript for my form and set the route in that:
  In the form init function:</p>
  
  <pre><code>$this-&gt;setDecorators(array(
      'PrepareElements',
          array(
              'ViewScript', array(
                      'viewScript' =&gt; 'forms/formView.phtml'
              ))));
  </code></pre>
  
  <p>and in the view file:</p>
  
  <pre><code>&lt;form method="post" action="&lt;?php echo $this-&gt;url(array(), 'route-name'); ?&gt;" enctype="application/x-www-form-urlencoded"&gt;
      &lt;?php
          foreach ($this-&gt;element-&gt;getElements() as $element)
          {
              echo $element;
          }
      ?&gt;
  &lt;/form&gt;
  </code></pre>