title: Embed a Collection of Forms Error: Could not determine access type for property
body: <p>I am trying to embed collection of <code>Tag</code> forms to <code>Service</code> form, according to <a href="https://symfony.com/doc/current/form/form_collections.html" rel="nofollow noreferrer">this tutorial</a>. <code>Tag</code> and <code>Service</code> entities have many-to-many relationship. </p>
  
  <p>Form is rendering correctly. But when I submit form, I get</p>
  
  <blockquote>
    <p>Could not determine access type for property "tagList"</p>
  </blockquote>
  
  <p>error. I don't understand why new <code>Tag</code> object is not added to the <code>Service</code> class by calling the <code>addTag()</code> method.</p>
  
  <p>ServiceType</p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
          -&gt;add('title', TextType::class, array(
              'label' =&gt; 'Title'
          ))
      ;
  
      $builder-&gt;add('tagList', CollectionType::class, array(
          'entry_type' =&gt; TagType::class,
          'allow_add' =&gt; true,
          'allow_delete' =&gt; true,
          'by_reference' =&gt; false
      )));
  }
  </code></pre>
  
  <p>Service class</p>
  
  <pre><code>{
  ....
   /**
   * @ORM\ManyToMany(targetEntity="Tag", mappedBy="serviceList",cascade={"persist"})
   */ 
  private $tagList;
  
  /**
   * @return ArrayCollection
   */
  public function getTagList()
  {
      return $this-&gt;tagList;
  }
  
  /**
   * @param Tag $tag
   * @return Service
   */
  public function addTag(Tag $tag)
  {
      if ($this-&gt;tagList-&gt;contains($tag) == false) {
          $this-&gt;tagList-&gt;add($tag);
          $tag-&gt;addService($this);
      }
  }
  
  /**
   * @param Tag $tag
   * @return Service
   */
  public function removeTag(Tag $tag)
  {
      if ($this-&gt;tagList-&gt;contains($tag)) {
          $this-&gt;tagList-&gt;removeElement($tag);
          $tag-&gt;removeService($this);
      }
      return $this;
  }
  }
  </code></pre>
  
  <p>Tag class</p>
  
  <pre><code> {
    /**
   * @ORM\ManyToMany(targetEntity="Service", inversedBy="tagList")
   * @ORM\JoinTable(name="tags_services")
   */
  private $serviceList;
   /**
   * @param Service $service
   * @return Tag
   */
  public function addService(Service $service)
  {
      if ($this-&gt;serviceList-&gt;contains($service) == false) {
          $this-&gt;serviceList-&gt;add($service);
          $service-&gt;addTag($this);
      }
      return $this;
  }
  
  /**
   * @param Service $service
   * @return Tag
   */
  public function removeService(Service $service)
  {
      if ($this-&gt;serviceList-&gt;contains($service)) {
          $this-&gt;serviceList-&gt;removeElement($service);
          $service-&gt;removeTag($this);
      }
      return $this;
  }
   }
  </code></pre>
  
  <p>ServiceController</p>
  
  <pre><code>  public function newAction(Request $request)
  {
      $service = new Service();
      $form = $this-&gt;createForm('AppBundle\Form\ServiceType', $service);
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
  
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $em-&gt;persist($service);
          $em-&gt;flush();
  
          return $this-&gt;redirectToRoute('service_show', array('id' =&gt; $service-&gt;getId()));
      }
  
      return $this-&gt;render('AppBundle:Service:new.html.twig', array(
          'service' =&gt; $service,
          'form' =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>