title: Symfony2 Many to Many not saved
body: <p>I have a M2M relationship, but when I create an item the relationship is not saved and I can't find where's the problem.
  The Model:</p>
  
  <pre><code>class Serie
   {    
  
  /**
   * @ORM\ManyToMany(targetEntity="Magazine", mappedBy="series")
   * */
  protected $magazines;
  
  /**
   * Constructor
   */
  public function __construct()
  {
      $this-&gt;magazines = new \Doctrine\Common\Collections\ArrayCollection();
  }
  
  /**
   * Add magazines
   *
   * @param MyList\DBBundle\Entity\Magazine $magazines
   * @return Serie
   */
  public function addMagazine(\MyList\DBBundle\Entity\Magazine $magazines)
  {
      $this-&gt;magazines[] = $magazines;
  
      return $this;
  }
  
  /**
   * Remove magazines
   *
   * @param MyList\DBBundle\Entity\Magazine $magazines
   */
  public function removeMagazine(\MyList\DBBundle\Entity\Magazine $magazines)
  {
      $this-&gt;magazines-&gt;removeElement($magazines);
  }
  
  /**
   * Get magazines
   *
   * @return Doctrine\Common\Collections\Collection 
   */
  public function getMagazines()
  {
      return $this-&gt;magazines;
  }
  }
  </code></pre>
  
  <p>The Magazine class:</p>
  
  <pre><code>class Magazine
  {
  
  /**
   * @ORM\ManyToMany(targetEntity="Serie" , inversedBy="magazines")
   * @ORM\JoinTable(name="magazines_series")
   * */
  protected $series;
  
  public function __construct()
  {
      $this-&gt;series = new \Doctrine\Common\Collections\ArrayCollection();
  }
  
  /**
   * Add series
   *
   * @param MyList\DBBundle\Entity\Serie $series
   * @return Magazine
   */
  public function addSerie(\MyList\DBBundle\Entity\Serie $serie)
  {
      $serie-&gt;addMagazine($this);
      $this-&gt;series[] = $serie;
  
      return $this;
  }
  
  /**
   * Remove series
   *
   * @param MyList\DBBundle\Entity\Serie $series
   */
  public function removeSerie(\MyList\DBBundle\Entity\Serie $series)
  {
      $this-&gt;series-&gt;removeElement($series);
  }
  
  /**
   * Get series
   *
   * @return Doctrine\Common\Collections\Collection 
   */
  public function getSeries()
  {
      return $this-&gt;series;
  }
  }
  </code></pre>
  
  <p>The Controller
      class SerieController extends Controller
      {
      public function newAction()
      {
          $entity = new Serie();
          $form   = $this->createForm(new SerieType(), $entity);</p>
  
  <pre><code>    return array(
          'entity' =&gt; $entity,
          'form'   =&gt; $form-&gt;createView(),
      );
  }
  
  /**
   * Creates a new Serie entity.
   *
   * @Route("/create", name="serie_create")
   * @Method("POST")
   * @Template("DBBundle:Serie:new.html.twig")
   */
  public function createAction(Request $request)
  {
      $entity  = new Serie();
      $form = $this-&gt;createForm(new SerieType(), $entity);
      $form-&gt;bind($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
          return $this-&gt;redirect($this-&gt;generateUrl('serie_show', array('id' =&gt; $entity-&gt;getId())));
      }
  
      return array(
          'entity' =&gt; $entity,
          'form'   =&gt; $form-&gt;createView(),
      );
  }
  }
  </code></pre>
  
  <p>And the Form:</p>
  
  <pre><code>class SerieType extends AbstractType
  {
  public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('title')
          -&gt;add('start')
          -&gt;add('end')
          -&gt;add('type')
          -&gt;add('status')
          -&gt;add('magazines','entity',array(
                  'class' =&gt; 'DBBundle:Magazine',
                  'multiple' =&gt; true,
                  'property' =&gt; 'name'
                  ))
      ;
  }
  
  public function setDefaultOptions(OptionsResolverInterface $resolver)
  {
      $resolver-&gt;setDefaults(array(
          'data_class' =&gt; 'MyList\DBBundle\Entity\Serie'
      ));
  }
  
  public function getName()
  {
      return 'mylist_dbbundle_serietype';
  }
  }
  </code></pre>
  
  <p>I know there are some questions about this (i.e. <a href="https://stackoverflow.com/questions/7044864/symfony2-doctrine-manytomany-relation-is-not-saved-to-database">Symfony2-Doctrine: ManyToMany relation is not saved to database</a>), but none of them have solved my problem.</p>