title: Symfony 2 removing form fields created using form type
body: <p>I have an EmployeeBasicInfoEntity having employee fields with some validation constraints using annotation. I am using this entity for employee Registration. Here is my EmployeeBasicInfoType</p>
  
  <pre><code>&lt;?php
  
  namespace Benerite\EmployeeBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  
  class EmployeeBasicInfoType extends AbstractType
  {
      /**
       * @param FormBuilderInterface $builder
       * @param array $options
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('company', 'entity', array(
                  'class' =&gt; 'BeneriteCompanyBundle:Company',
                  'choice_label' =&gt; 'companyName',
                  'placeholder' =&gt; 'Please select',
              ))
              -&gt;add('employeeIdentificationCode')
              -&gt;add('employeePassword', 'password')
              -&gt;add('employeeFirstName')
              -&gt;add('employeeMiddleName')
              -&gt;add('employeeLastName')
              -&gt;add('employeeDob','date',array(
                  'years' =&gt; range(date('Y'),date('Y',strtotime('-50 years')) ),
                  'required' =&gt; True,
                  )
              )
              -&gt;add('employeeGender', 'choice', array(
                      'choices'  =&gt; array('m' =&gt; 'Male', 'f' =&gt; 'Female', 't' =&gt; 'Transgender', 'na' =&gt; 'Do not want to disclose'),
                      'expanded'      =&gt; true,
                      'multiple'      =&gt; false, 'required' =&gt; true, 'data' =&gt; 'na',
                  )
              )
          ;
      }
  
      /**
       * @param OptionsResolverInterface $resolver
       */
      public function setDefaultOptions(OptionsResolverInterface $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'Benerite\EmployeeBundle\Entity\EmployeeBasicInfo'
          ));
      }
  
      /**
       * @return string
       */
      public function getName()
      {
          return 'benerite_employeebundle_employeebasicinfo';
      }
  }
  </code></pre>
  
  <p><strong>I have created a controller for user login using the same form type</strong> and i don't want show specific fields. I have made some changes in my controller. Please check my controller</p>
  
  <pre><code>    &lt;?php
  
  namespace Benerite\EmployeeBundle\Controller;
  
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  use Benerite\EmployeeBundle\Entity\EmployeeBasicInfo;
  use Benerite\EmployeeBundle\Form\EmployeeBasicInfoType;
  
  /**
   * User controller.
   *
   * @Route("/user")
   */
  class UserController extends Controller
  {
      /**
       * Creates a new Company entity.
       *
       * @Route("/login", name="user_login")
       * @Method("POST|GET")
       * @Template("BeneriteEmployeeBundle:User:login.html.twig")
       */
      public function loginAction(Request $request)
      {
          $entity = new EmployeeBasicInfo();
          $form = $this-&gt;createForm(new EmployeeBasicInfoType(), $entity, array(
              'action' =&gt; $this-&gt;generateUrl('user_login'),
              'method' =&gt; 'POST',
          ));
  
          $form-&gt;remove('company')
                  -&gt;remove('employeeFirstName')
                  -&gt;remove('employeeMiddleName')
                  -&gt;remove('employeeLastName')
                  -&gt;remove('employeeDob')
                  -&gt;remove('employeeGender');
  
          $form-&gt;add('submit', 'submit', array('label' =&gt; 'Log In'));
          $form-&gt;handleRequest($request);
  
  
  
  
  
          if ($form-&gt;isValid()) {
  
  
  
          }
  
          return array(
              'login_form'=&gt;$form-&gt;createView()
          );    
      }
  
  
  
  }
  </code></pre>
  
  <p>With this piece of code, I am able to remove the fields. But form->isValid() is always returning false. Please advise me where I am going wrong. Is this the correct way of doing it?</p>