title: How to get form values in Symfony2 controller
body: <p>I am using a login form on Symfony2 with the following controller code</p>
  
  <pre><code>public function loginAction(Request $request)
  {
      $user = new SiteUser();
      $form = $this-&gt;createForm(new LoginType(), $user);
  
  
      if ($request-&gt;getMethod() == 'POST') {
          $form-&gt;bindRequest($request);
          $data = $form-&gt;getValues();
          // Need to do something with the data here
      }
  
      return $this-&gt;render('GDSiteBundle::header.html.twig', array('form' =&gt; $form-&gt;createView()));
  }
  </code></pre>
  
  <p>But I am getting the following warning:</p>
  
  <blockquote>
    <p>Warning: array_replace_recursive() [function.array-replace-recursive]: Argument #1 is not an array in \vendor\symfony\src\Symfony\Component\Form\Form.php line 593
    500 Internal Server Error - ErrorException</p>
  </blockquote>
  
  <p>Can someone help me understand whats incorrect, and how I can fix it? Thanks.</p>
  
  <p>Update:
  The twig file is something like this:</p>
  
  <pre><code>&lt;div class="form"&gt;
      {{ form_errors(form) }}
      &lt;form action="{{ path('site_user_login') }}" method="POST" {{ form_enctype(form) }}&gt;
          &lt;div class="level1"&gt;
              {{ form_row(form.username) }}
              &lt;a href="javascript:void(0)" id="inscription"&gt;{% trans %}Registration{% endtrans %}&lt;/a&gt;
          &lt;/div&gt;
          &lt;div class="level2"&gt;
              {{ form_row(form.pwd_hash) }}
              &lt;div class="forget_pass"&gt;&lt;a href="#" id="frgt"&gt;{% trans %}Forgot Password ?{% endtrans %}&lt;/a&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;input type="submit" class="submit" name="login" value/&gt;
          &lt;div class="clr"&gt;&lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is the function in the Form's Type</p>
  
  <pre><code>public function buildForm(FormBuilder $builder, array $options)
  {
      $builder-&gt;add('username', 'text', array('label' =&gt; 'Username : '));
      $builder-&gt;add('pwd_hash','password', array('label' =&gt; 'Password : '));
  }
  </code></pre>
  
  <p>Here is the route:</p>
  
  <pre><code>site_user_login:
      pattern: /{_locale}/login
      defaults: {_controller: GDSiteBundle:SiteUser:login}
  </code></pre>