title: Symfony: Get data from subform (CollectionType)
body: <p>I have a ManyToOne relation between two entities <code>Parent</code> and <code>Child</code> so in the <code>FormType</code> I have used <code>CollectionType</code> as described below:<br></p>
  
  <pre><code>class ParentType extends AbstractType
  {
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('name')
              -&gt;add('childs', CollectionType::class, array(
                  'entry_type' =&gt; ChildType::class,
              ));
      }
  }
  </code></pre>
  
  <p>And in the ChildType class I want to get the embeded object using EventListener:<br></p>
  
  <pre><code>class ChildType extends AbstractType
  {
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('name')
              -&gt;add('lastName');
  
          $builder-&gt;addEventListener(
              FormEvents::POST_SET_DATA,//---after setting data
              function (FormEvent $event) {
                  die(var_dump($event-&gt;getData()));//---this gives me null
              }
          );
      }
  }
  </code></pre>
  
  <p>The result I get is null although I have passed a full object to the form in the controller:<br></p>
  
  <pre><code>$parent = new Parent('Test');
  $childs = array(
      'test1' =&gt; 'test1',
      'test2' =&gt; 'test2',
  );
  foreach ($childs as $key =&gt; $value){
      $c = new Child($key, $value);
      $parent-&gt;addChild($c);
  }
  
  $form = $this-&gt;createForm(ParentType::class, $parent);
  </code></pre>
  
  <p>class <code>Parent</code>:<br></p>
  
  <pre><code>class Parent{
     /**
       * @var ArrayCollection*
       * @ORM\OneToMany(targetEntity="Child", mappedBy="parent", cascade={"persist", "remove"})
       * @ORM\JoinColumn(nullable = true)
       */
      private $childs;
  
      /**
       * Constructor
       */
      public function __construct()
      {
           $this-&gt;childs= new \Doctrine\Common\Collections\ArrayCollection();
      }
  
      /**
       * Add child
       *
       * @param \AppBundle\Child $child
       *
       * @return Parent
       */
      public function addChild(\AppBundle\Child $child)
      {
          $this-&gt;childs[] = $child;
  
          return $this;
      }
  
      /**
       * Remove child
       *
       * @param \AppBundle\Child $child
       */
      public function removeChild(\AppBundle\Child $child)
      {
          $this-&gt;childs-&gt;removeElement($child);
      }
  
      /**
       * Get childs
       *
       * @return \Doctrine\Common\Collections\Collection
       */
      public function getChilds()
      {
          return $this-&gt;childs;
      }
  }
  </code></pre>