title: FOSRestBundle posting json data to a form not working
body: <p>I am stack with posting JSON data to a form in the controller. The entity is not filled in with properties that I am sending, here it's how it looks like:</p>
  
  <pre><code>// Controller
  
  class UserApiController extends FOSRestController
  {
      // works fine
      public function cgetAction()
      {
          return $this-&gt;get('model.user')-&gt;getAllUsers();
      }
  
      // works fine
      public function getAction($id)
      {
          return $this-&gt;get('model.user')-&gt;getUserById($id);
      }
  
      // this method fails
      public function postAction(Request $request)
      {
          $form = $this-&gt;createForm(new UserType(), new User());
          $form-&gt;bind($request);
  
          if($form-&gt;isValid())
          {
              die('are you valid or not??');
          }
  
          return $this-&gt;view($form, 400);
      }
  }
  </code></pre>
  
  <p>Entity looks like a regular one and form as well.</p>
  
  <p>I have a test controller that sends the json data to the api:</p>
  
  <pre><code>public function testJsonPostAction()
      {
          $client = static::createClient();
          $client-&gt;request(
              'POST',
              '/api/1.0/users',
              array(),
              array(),
              array('CONTENT_TYPE' =&gt; 'application/json'),
              '{"firstName": "John", "lastName": "Doe", "emailAddress": "something@somewhere.com", "sex": "1"}'
          );
  
          var_dump($client-&gt;getResponse()-&gt;getContent());
      }
  </code></pre>
  
  <p>And the validation:</p>
  
  <pre><code>Software\Bundle\Entity\User:
      properties:
          firstName:
              - NotBlank: ~
              - Length:
                  min: 2
                  max: 255
          lastName:
              - NotBlank: ~
              - Length:
                  min: 2
                  max: 255
  </code></pre>
  
  <p>Ok, the problem is that $form is always not valid. When I dump the $form->getData() content I got my User entity but firstName, lastName etc is not filled in. Instead I got validation errors obviously but here's another but:</p>
  
  <p>Why $form->bind($request) (I know it's deprecated) returns this (which is more less good):</p>
  
  <pre><code>{"code":400,"message":"Validation Failed","errors":{"children":{"firstName":{"errors":["This value should not be blank."]},"lastName":{"errors":["This value should not be blank."]},"emailAddress":{"errors":["This value should not be blank."]},"sex
  ":[],"locale":[]}}}
  </code></pre>
  
  <p>and the same code but with $form->handleRequest($request) returns this:</p>
  
  <pre><code>{"children":{"firstName":[],"lastName":[],"emailAddress":[],"sex":[],"locale":[]}}
  </code></pre>
  
  <p>What's the difference? Since I thought handleRequest is a replacement for bind.
  I tried already I think all the solutions on the Internet and every time is something different and I can't get it work. Documentation of FOSRestBundle is very poor, it says all about getting stuff, but almost nothing about posting.</p>
  
  <p>Any help much appreciated.</p>