title: Creating a REST API in Symfony2 - empty input
body: <p>I've been following <a href="http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/" rel="nofollow noreferrer">this guide</a> as close as possible to create a simple REST API in Symfony2.</p>
  
  <p>Unfortunately whatever I post to the API I always get:</p>
  
  <pre><code>{"children":{"firstName":{"errors":["This value should not be blank."]},"lastName":{"errors":["This value should not be blank."]},"email":{"errors":["This value should not be blank."]},"password":{"errors":["This value should not be blank."]},"dob":{"errors":["This value should not be blank."],"children":{"year":[],"month":[],"day":[]}},"tutorialWatched":{"errors":["This value should not be blank."]},"challengeEmails":{"errors":["This value should not be blank."]},"mailingList":{"errors":["This value should not be blank."]}}}
  </code></pre>
  
  <p>My validation is as follows:</p>
  
  <pre><code>LifeMirror\APIBundle\Model\Users:
      properties:
          firstName:
              - NotBlank:
          lastName:
              - NotBlank:
          email:
              - NotBlank:
              - Email:
          password:
              - NotBlank:
          dob:
              - NotBlank:
              - Date:
          tutorialWatched:
              - NotBlank:
              - Choice:
                  choices: [0, 1]
          challengeEmails:
              - NotBlank:
              - Choice:
                  choices: [0, 1]
          mailingList:
              - NotBlank:
              - Choice:
                  choices: [0, 1]
  </code></pre>
  
  <p>And my controller is:</p>
  
  <pre><code>class RegisterController extends Controller
  {
      public function indexAction()
      {
          return $this-&gt;processForm(new Users());
      }
  
      private function processForm(Users $user)
      {
          $statusCode = $user-&gt;isNew() ? 201 : 204;
  
          $form = $this-&gt;createForm(new UsersType(), $user);
          $form-&gt;bind($this-&gt;getRequest());
  
          if ($form-&gt;isValid()) {
              $user-&gt;save();
  
              $response = new Response();
              $response-&gt;setStatusCode($statusCode);
              return $response;
          }
          $view = View::create($form, 400);
          $view-&gt;setFormat('json');
          return $view;
      }
  }
  </code></pre>
  
  <p>I can var_dump <code>$this-&gt;getRequest()</code> and can see the data are there, but I'm not sure why the validator is complaining.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's the form:</p>
  
  <pre><code>namespace LifeMirror\APIBundle\Form\Type;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  
  class UsersType extends AbstractType
  {
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder-&gt;add('firstName');
          $builder-&gt;add('lastName');
          $builder-&gt;add('email');
          $builder-&gt;add('password');
          $builder-&gt;add('dob');
          $builder-&gt;add('tutorialWatched');
          $builder-&gt;add('challengeEmails');
          $builder-&gt;add('mailingList');
      }
  
      /**
       * {@inheritdoc}
       */
      public function getDefaultOptions(array $options)
      {
          return array(
              'data_class' =&gt; 'LifeMirror\APIBundle\Model\Users',
              'csrf_protection'   =&gt; false,
          );
      }
  
      /**
       * {@inheritdoc}
       */
      public function getName()
      {
          return 'users';
      }
  }
  </code></pre>
  
  <p>And my input:
  <img src="https://i.stack.imgur.com/x0Se3.png" alt="enter image description here"></p>
  
  <p><strong>EDIT 2:</strong>
  Content tof $_REQUEST:</p>
  
  <pre><code>array(9) { ["firstName"]=&gt; string(5) "James" ["lastName"]=&gt; string(6) "Hadley" ["email"]=&gt; string(9) "fd@fd.com" ["password"]=&gt; string(7) "test123" ["dob"]=&gt; string(33) "{'year':1991,'month':08,'day':02}" ["location"]=&gt; string(9) "Lancaster" ["tutorialWatched"]=&gt; string(1) "0" ["challengeEmails"]=&gt; string(1) "0" ["mailingList"]=&gt; string(1) "0" }
  </code></pre>
  
  <p><strong>EDIT 3:</strong>
  HTML form:</p>
  
  <pre><code>&lt;form action="http://www.lifemirror.org/api/register/" method="post"&gt;
      &lt;input type="hidden" name="firstName" value="James" /&gt;
      &lt;input type="hidden" name="lastName" value="Hadley" /&gt;
      &lt;input type="hidden" name="email" value="fd@fd.com" /&gt;
      &lt;input type="hidden" name="password" value="test123" /&gt;
      &lt;input type="hidden" name="dob" value="{'year':1991,'month':08,'day':02}" /&gt;
      &lt;input type="hidden" name="location" value="Lancaster" /&gt;
      &lt;input type="hidden" name="tutorialWatched" value="0" /&gt;
      &lt;input type="hidden" name="challengeEmails" value="0" /&gt;
      &lt;input type="hidden" name="mailingList" value="0" /&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>