title: Symfony2 forms and many to many relation
body: <p>(Symfony version 2.7)</p>
  
  <p>Hi, I have a problem with form in field with many to many relation.</p>
  
  <pre><code>Class Notification {
  
  public function __construct()
  {
      $this-&gt;assigneduser = new \Doctrine\Common\Collections\ArrayCollection();
      $this-&gt;flags = new ArrayCollection();
  }
  
  /**
   * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Flag", inversedBy="notificationflags", cascade={"persist"})
   * @ORM\JoinTable(name="sla_notificationflags",
   *                  joinColumns={@ORM\JoinColumn(name="notification_id", referencedColumnName="notificationId")},
   *                  inverseJoinColumns={@ORM\JoinColumn(name="flag_id", referencedColumnName="flagId")}
   *               )
   *
  */
  private $flags;
  
  /**
   * Add flag
   *
   * @param \AppBundle\Entity\Flag $flag
   * @return Notification
   */
  public function addFlag(Flag $flag)
  {
      $flag-&gt;addNotificationflag($this);
      $this-&gt;flags[] = $flag;
      return $this;
  }
  
  }
  
  Class Flag {
  
  public function __construct()
  {
      $this-&gt;notificationflags = new \Doctrine\Common\Collections\ArrayCollection();
  }
  
  /**
   * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Notification", mappedBy="flags")
   */
  protected $notificationflags;
  
  /**
   * Add notificationflags
   *
   * @param \AppBundle\Entity\Notification $notificationflag
   * @return Flag
   */
  public function addNotificationflag(Notification $notificationflag)
  {
  
      if(!$this-&gt;notificationflags-&gt;contains($notificationflag)) {
          $this-&gt;notificationflags-&gt;add($notificationflag);
      }
  
      return $this;
  }
  
  
  
  }
  </code></pre>
  
  <p>My Form Class</p>
  
  <pre><code>class NotificationSingleFormType extends AbstractType
  {
  
  public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder-&gt;add('flags','entity',array(
              'label' =&gt; false,
              'attr' =&gt; array(
                  'class' =&gt; 'select'
              ),
              'class' =&gt; 'AppBundle\Entity\Flag',
              'query_builder' =&gt; function(EntityRepository $er) {
                  return $er-&gt;createQueryBuilder('p')
                      -&gt;addOrderBy('p.name','ASC');
              },
              'property' =&gt; 'name',
              'required' =&gt; false
      )
      );
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When i send the form i see error:</p>
  
  <blockquote>
    <p>Neither the property "flags" nor one of the methods
    "addFlag()"/"removeFlag()", "setFlags()", "flags()", "__set()" or
    "__call()" exist and have public access in class
    "AppBundle\Entity\Notification".</p>
  </blockquote>