title: How do I get Symfony forms to work with a REST API?
body: <p>I'm currently trying to get symfony forms to work with my post and put rest api endpoint.</p>
  
  <p>Currently I have:</p>
  
  <pre><code>$request = $this-&gt;getRequest();
  $cc = new CreditCard();
  $form = $this-&gt;createForm(new CreditCardType(), $cc);
  
  $form-&gt;handleRequest($request);
  
  if ($form-&gt;isValid()) {
    //...
  }
  </code></pre>
  
  <p>However, the form is never valid.  Looking into the problem, it seems that the form's isSubmitted field is false, so it never passes validation.  Also, since this is an api call, I have the csrf_protection set to false in the creditcardtype.</p>
  
  <p>Here is an example of what data I'm having the user submit:</p>
  
  <pre><code>{
    "credit_card": {
       "name" : "Example Name"
       ...
    }
  }
  </code></pre>
  
  <p>How do I get this post/put request to be registered as submitted and have the form validator pass?  Thanks.</p>