title: Error: Call to a member function format() on a non-object with \DateTime
body: <p>I have one problem with my Symfony project. I have one entity with many \DateTime like this :</p>
  
  <pre><code>/**
  * @var \DateTime
  *
  * @ORM\Column(name="date_debut", type="datetime", length=255)
  */
  protected $dteDebut ;
  
  function getDteDebut() {return $this-&gt;dteDebut;}
  
  function setDteDebut(\DateTime $dteDebut) {$this-&gt;dteDebut = $dteDebut;}
  </code></pre>
  
  <p>I use formBuilder with datetime like this:</p>
  
  <pre><code>$builder-&gt;add('dteDebut', 'datetime', array(
              'label' =&gt; 'Date de début :',
              'date_widget' =&gt; 'single_text',
              'time_widget' =&gt;'single_text'
          ));
  </code></pre>
  
  <p>And one simple fonction to use my form:</p>
  
  <p>public function organiserAction() {</p>
  
  <pre><code>    $em=$this-&gt;getDoctrine()-&gt;getManager();
      $orga = new \CCF\CCFBundle\Entity\Organiser;
      $form = $this-&gt;createForm(new \CCF\CCFBundle\Form\OrganiserForm(), $orga);
      $request = $this-&gt;get('request');
  
      if ($request-&gt;getMethod() == 'POST') {
          $form-&gt;bind($request);
          var_dump($form-&gt;get('dteDebut')-&gt;getData());
          if ($form-&gt;isValid()) {                
              $em-&gt;persist($orga);
              $em-&gt;flush();
              return $this-&gt;redirect($this-&gt;generateUrl('organiser_homepage'));
          }
      }
      //on passe la méthode createView() à la vue pour qu'elle l'affiche
      return $this-&gt;render('CCFBundle:Organiser:create.html.twig',array("form"=&gt;$form-&gt;createView(),));
  }
  </code></pre>
  
  <p>When I valid the form I have one error </p>
  
  <blockquote>
    <p>Error: Call to a member function format() on a non-object</p>
  </blockquote>
  
  <p>Stack Trace</p>
  
  <p>in vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateType.php at line 53   -</p>
  
  <pre><code>public function convertToDatabaseValue($value, AbstractPlatform $platform)
  {
      return ($value !== null)
          ? $value-&gt;format($platform-&gt;getDateFormatString()) : null;
  }
  /**
  </code></pre>
  
  <p>I do not understand where does this error, can you help me?</p>