title: Symfony2: how to get the Type that a form is constructed from
body: <p>I'm trying to dynamically generate my forms based on the user's permissions for that I have created a extension which adds listeners to forms and filters their fields accordingly.this works just fine However I'm having trouble with getting the typeName (returned from the <code>getName</code> method for classes which implement the <code>FormTypeInterface</code>) of each field (which is <code>FormInterface</code>).I've tried <code>FormInterface::getName</code> but that returns the field name that is given to the builder e.g: <code>$builder-&gt;add('fieldName',new FooType())</code> when I call <code>getName</code> on a <code>FormInterface</code> that is constructed like this I get "fieldName".What I want is the returned value from <code>FooType::getName</code>.How can I do that?I have also checked <code>FormInterface-&gt;getConfig-&gt;getName()</code> but that also gave the same same Result.the code for the listener:</p>
  
  <pre><code>class FooListener implements EventSubscriberInterface{
  public static function getSubscribedEvents()
  {
      //set low priority so it's run late
      return array(
          FormEvents::PRE_SET_DATA =&gt; array('removeForbiddenFields', -50),
      );
  }
  
  public function removeForbiddenFields(FormEvent $event){
  
      $form = $event-&gt;getForm();
  
      $formName = $form-&gt;getName();/*what I want for this is to return the name of the
      type of the form.e.g: for the field that is construced with the code below 
      it must return FooType::getName*/
  
      $fields = $form-&gt;all();
  
      if($fields){
          $this-&gt;removeForbiddenFormFields($form, $formName, $fields);
      }
  }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>class barType extends AbstractType{   
  
  public function buildForm(FormBuilderInterface $builder, array $options){
      $builder-&gt;add('fieldName',new FooType());
  }
  ....
  
  }
  </code></pre>