title: Update Entity with form values Symfony2 Framework
body: <p>I'm using Symfony2 Framework, and I want to update an entity with data from a form.</p>
  
  <p>I'm using the same controller to populate the form  with some data, and at the same time I'm using it to make the update query in the database. If I use $em->persist($foo) it does save exactly what I want, but I don't want to save it like it's new data, I want to update.</p>
  
  <p>Reading symfony2 book, it says that $em->flush() is all we need so we can update.</p>
  
  <p>I think I'm really close but of course I'm missing something.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public function actualizarCurriculoAction($id){
  
    $curriculo = new Curriculittle();
    $form = $this-&gt;createForm(new CurriculittleType(), $curriculo);
    $request = $this-&gt;getRequest();
  
    if ($request-&gt;getMethod() == 'POST') {
  
       $form-&gt;bindRequest($request);
  
       $lselect=$this-&gt;get('request')-&gt;request-&gt;get('lselect');
       $edad=$this-&gt;get('request')-&gt;request-&gt;get('edad');
       $estado=$this-&gt;get('request')-&gt;request-&gt;get('estadoselect'); 
  
       if ($form-&gt;isValid()) {
  
  
          $curriculo-&gt;setUsalentes($lselect);
          $curriculo-&gt;setEdad($edad);
          $curriculo-&gt;setEstado($estado);    
  
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          /*em-&gt;persist($curriculo);*/ 
  
          $em-&gt;flush(); /*the above line is in comment because I just want to update*/
  
                              /*At this point the entity should be updated, but it's not*/
  
          /*Llamando a la plantilla de listados*/
          $curriculos = $em-&gt;getRepository('SofLaSoflaBundle:Curriculittle')-&gt;findAll();
  
          /*Enviando los datos a la plantilla y Renderizandola*/
          return $this-&gt;render('SofLaSoflaBundle:Default:listado.html.twig', array('curriculos' =&gt; $curriculos));
       }
    }
  
    $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
    $trabajador=$em-&gt;getRepository('SofLaSoflaBundle:Curriculittle')-&gt;find($id);
    return $this-&gt;render('SofLaSoflaBundle:Default:curriculo.html.twig', array('form' =&gt; $form-&gt;createView(), 'curriculo' =&gt; $trabajador));
  }
  </code></pre>
  
  <p>So, need help with this please. :)</p>