title: Cloning object after getting data from a form in Symfony2
body: <p>I'm sure I'm missing something very basic here.</p>
  
  <p>I have a form, and when the user updates the fields of the form I don't want to update the underlying entity but want to create a new entity with the new values.</p>
  
  <p>To clone Doctrine entities I followed the indication <a href="https://stackoverflow.com/questions/9071094/how-to-re-save-the-entity-as-another-row-in-doctrine-2">here</a>. </p>
  
  <p>So my code is (let's say I want to clone the object with id=3:</p>
  
  <pre><code>    $id = 3;
      $storedBI = $this-&gt;getDoctrine()
                       -&gt;getRepository('AppBundle:BenefitItem')
                       -&gt;find($id);
      $form = $this-&gt;createForm(new BenefitItemFormType(), $storedBI);
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isValid())
          {
              $em = $this-&gt;getDoctrine()-&gt;getManager();  
              $newBI = clone $form-&gt;getData();
              $em-&gt;persist($newBI);
              $em-&gt;flush();
          }
  </code></pre>
  
  <p>It simply does not work. It properly creates a new object with the new data passed from the form (which is ok), but also updates the "old" stored object with the same new data.</p>
  
  <p>Any idea?</p>