title: Symfony2 (>= 2.3): How to listen to parent form event from child?
body: <p>I have a custom FormType, which needs to add itself to the parent Entity when the parent Form persists.</p>
  
  <p>In Symfony &lt; 2.3 this could be done by doing the following:</p>
  
  <pre><code>class FooType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          parent::buildForm($builder, $options);
          ...
          $builder-&gt;getParent()-&gt;addEventSubscriber(new FooSubscriber)
      }
  }
  
  class FooSubscriber implements EventSubscriberInterface
  {
      static function getSubscribedEvents()
      {
          return array(
              FormEvents::POST_SUBMIT =&gt; 'postSubmit'
          );
      }
  }
  </code></pre>
  
  <p>But after upgrading to Symfony 2.6 I've discovered that <code>$builder-&gt;getParent()</code> has been removed. But now I can't listen to the parent being submitted.</p>
  
  <p>So I added the listener to my builder and referenced the parent from within the Subscriber. But this doesn't really work, since I do a check on the parent form being valid - which it isn't, since it's not submitted yet:</p>
  
  <pre><code>function postSubmit(FormEvent $e)
  {
      if ($e-&gt;getForm()-&gt;getParent()-&gt;getRoot()-&gt;isValid()) {
          //this gives 'false'
  </code></pre>
  
  <p>This false is caused by the next piece of code:</p>
  
  <pre><code>// Symfony\Component\Form\Form.php @ line 744
  public function isValid()
  {
      if (!$this-&gt;submitted) {
          return false;
      }
  </code></pre>
  
  <p>And because the parent form first loops through all the childs and submits that, before setting <code>$this-&gt;submitted = true</code> on itself... I'm not sure if the parent is valid.</p>
  
  <hr>
  
  <p><strong>TL;DR</strong></p>
  
  <p>How can I add an Eventlistener to my parent Form, without having to adjust my parent Form? I want my FooType be something I can add to all forms, without having to know/remember to do some logic for that FooType specific.</p>