title: Zend Form in Modal - Submit Form
body: <p>I have a question about using a zend form in a twitter bootstrap modal. This is what I have:</p>
  
  <p>In my Controller:</p>
  
  <pre><code>public function accountAction() {
  
      $form = new Form_CancelAccount();
      $this-&gt;view-&gt;form = $form;
  
      // Some executions and view params for the view, ex:
      /*if ($user-&gt;getRecurlyId() &amp;&amp; NameSpace_Feature_Access_RoleHelper::hasAccess('show_billing')) {
          try {
              $account = Recurly_Account::get($user-&gt;getRecurlyId());
              $this-&gt;view-&gt;token = $account-&gt;hosted_login_token;
              $this-&gt;view-&gt;show_billing = true;
          } catch (Recurly_NotFoundError $e) {
              $this-&gt;view-&gt;show_billing = false;
          }
      } else {
          $this-&gt;view-&gt;show_billing = false;
      }*/
  
      if ($this-&gt;getRequest()-&gt;isPost() &amp;&amp; $form-&gt;isValid($_POST)) {
  
          $data = $form-&gt;getValues();
          var_dump($data);
  
      } else {
          var_dump("it didn't work!");
      }
  }
  </code></pre>
  
  <p>My CancelAccount Form:</p>
  
  <pre><code>&lt;?php
  
  class Form_CancelAccount extends NameSpace_Form_Base
  {
    public function __construct($options = null) {
  
      parent::__construct($options);
  
      $this-&gt;setName('cancelaccount');
  
      $element = new Zend_Form_Element_Radio('reason');
      $element-&gt;addMultiOptions(array(
          'It is really bad!' =&gt; 'bad',
          'No time for it!' =&gt; 'notime',
          'Other option:' =&gt; 'otheroption'
      ))-&gt;setDecorators(array(array('ViewScript', array('viewScript' =&gt; 'user/radio.phtml'))));
  
      $this-&gt;addElement($element);
  
      $this-&gt;addElement('text', 'otheroption', array(
          'attribs' =&gt; array(
              'class' =&gt; 'input-block-level otheroption',
              'size'  =&gt; 30,
              'placeholder' =&gt; 'Other option'
          ),
          'decorators' =&gt; $this-&gt;elementDecoratorsNoTag
      ));
    }
  }
  </code></pre>
  
  <p>In my View:</p>
  
  <pre><code>// Some data sent from the controller
  &lt;h4&gt;Delete account&lt;/h4&gt;
  &lt;p&gt;Deleting of your account implies your account and the related data will be deleted. Please note that this is not reversible.&lt;/p&gt;
  
  &lt;button type="button" data-target="#cancelModal" data-toggle="modal" class="btn btn-primary"&gt;Delete account&lt;/button&gt;
  &lt;div class="modal hide fade" id="cancelModal"&gt;
  &lt;div class="modal-header"&gt;
      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;x&lt;/button&gt;
      &lt;h3&gt;Modal header&lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="modal-body"&gt;
      &lt;?php echo $this-&gt;form; ?&gt;
  &lt;/div&gt;
  &lt;div class="modal-footer"&gt;
      &lt;input type="submit" class="btn btn-default" value="OK" form="cancelaccount"&gt;
      &lt;a id="cancel" class="btn btn-default close" data-dismiss="modal"&gt;Cancel&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>But I always get the output <code>'it didn't work!'</code> from the var_dump when the form isn't valid ... . What's the best way to do this? And how does it comes it's always not valid?</p>
  
  <p><strong>UPDATE:</strong><br>
  When I leave out the <code>"&amp;&amp; $form-&gt;isValid($_POST)"</code> in my if statement I come in the statement, but my var_dump shows this:</p>
  
  <blockquote>
    <p>array (size=2)<br>
        'reason' => null<br>
        'otheroption' => null</p>
  </blockquote>
  
  <p>My response:
  <img src="https://i.stack.imgur.com/J0kpo.png" alt="enter image description here"></p>
  
  <p>The problem is that my radiobuttons aren't valid ... How can I fix this?</p>