title: Symfony update entity with form
body: <p>I'm building a simple restfull API with basic crud actions.</p>
  
  <p>I try to update an entity through a PUT request but my form doesn't validate and also givesno errors when sending the put request. What am I doing wrong? FYI, the postAction with the same FormType does work!</p>
  
  <p><strong>EventController::putEventsAction</strong></p>
  
  <pre><code>/**
   * Update excisting event.
   *
   * @return event
   */
  public function putEventsAction($id, Request $request)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $event = $em-&gt;find('JdsApiBundle:Event', $id);
  
      if(!$event) {
          $view = $this-&gt;view(["id" =&gt; $id], Codes::HTTP_NOT_FOUND);
          return $this-&gt;handleView($view);
      }
  
      $form = $this-&gt;createForm(EventType::class, $event);
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid()) {
  
          $em-&gt;persist($event);
          $em-&gt;flush();
  
          $view = $this-&gt;view($event, Codes::HTTP_OK);
  
          return $this-&gt;handleView($view);
      }
  
      $logger = $this-&gt;get('logger');
      $logger-&gt;info((string) $form-&gt;getErrors(true));
  
      return (string) $form-&gt;getErrors(true);
  
      // return array(
      //  'form' =&gt; $form,
      // );
  }
  </code></pre>
  
  <p><strong>EventType</strong></p>
  
  <pre><code>class EventType extends AbstractType
  {
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('title')
              -&gt;add('startDate', DateTimeType::class, array(
                  'widget' =&gt; 'single_text',
                  'format' =&gt; 'yyyy-MM-dd', // this is actually the default format for single_text
              ))
              -&gt;add('endDate', DateTimeType::class)
              -&gt;add('description')
              -&gt;add('color')
          ;
      }
  
      /**
       * @param OptionsResolver $resolver
       */
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'csrf_protection' =&gt; false,
              'data_class' =&gt; 'Jds\ApiBundle\Entity\Event'
          ));
      }
  }
  </code></pre>