title: Delete an item from oneToMany relationship
body: <p>I have the following Gallery entity</p>
  
  <pre><code>class Gallery
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var ArrayCollection
       * @ORM\OneToMany(targetEntity="Tessa\GalleryBundle\Entity\Photo", mappedBy="gallery", cascade={"persist", "remove"})
       */
      private $photos;
  
      /* ... */
  }
  </code></pre>
  
  <p>This <code>gallery</code> is linked with a <code>manyToOne</code> relationship to a <code>PointOfInterest</code> entity. Here is the declaration</p>
  
  <pre><code>class PointOfInterest
  {
   /* ... */
   /**
   * @ORM\ManyToOne(targetEntity="Tessa\GalleryBundle\Entity\Gallery", cascade={"persist", "remove"})
   * @ORM\JoinColumn(nullable=false)
   */
  private $gallery;
   /* ... */
  </code></pre>
  
  <p>I also use a Form to update the <code>PointOfInterest</code> entity. Here is the form declaration</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
              -&gt;add('name',           'text')
              -&gt;add('gallery',        new GalleryType())
         ;
  }
  </code></pre>
  
  <p>and the <code>GalleryType</code> declaration.</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('photos', 'collection', array('type'          =&gt; new PhotoType(),
                                              'required'      =&gt; false,
                                              'allow_add'     =&gt; true,
                                              'allow_delete'  =&gt; true,
                                              'by_reference'  =&gt; false
                                              ))
      ;
  }
  </code></pre>
  
  <p>When I edit the <code>PoI</code> I can add photos to the gallery without problem, but I can't delete anything.</p>
  
  <p>I tried to hook on gallery <code>PreUpdate</code>, but it is never called. I printed output in <code>removePhotos</code> method of <code>Gallery</code> entity, and the photos are removed from the gallery. I then suspect the Gallery to never be persisted.</p>
  
  <p>Here is the code when I persist the <code>PoI</code> after editing.</p>
  
  <pre><code>private function handleForm($elem, $is_new)
  {
      $form = $this-&gt;createForm(new CircuitType, $elem);
  
      $request = $this-&gt;get('request');
      if ($request-&gt;getMethod() == 'POST') {
          $form-&gt;bind($request);
  
          if ($form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($elem);
              $em-&gt;flush();
  
              return $this-&gt;redirect($this-&gt;generateUrl('tessa_circuit_index'));
          }
      }
  
      return $this-&gt;render('TessaUserBundle:Circuits:add.'.'html'.'.twig',
          array(
              'form' =&gt; $form-&gt;createView(),
              'is_new' =&gt; $is_new,
          ));
  }
  </code></pre>