title: Hide a field according to its role Symfony 3
body: <p>First sorry for my english because is not great!</p>
  
  <p>So I want to hide a field according to it's role because if I make with Twig the field to display on the bottom form</p>
  
  <p>My code for understand, this's my LinkType : </p>
  
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
  {
      $builder
  
      -&gt;add('title')
      -&gt;add('link')
      -&gt;add('description')
  
      // this field to hidden according the role
      -&gt;add('published', CheckboxType::class);
  }
  
  /**
   * {@inheritdoc}
   */
  public function configureOptions(OptionsResolver $resolver)
  {
      $resolver-&gt;setDefaults(array(
          'data_class' =&gt; 'AppBundle\Entity\Link'
      ));
  }
  
  /**
   * {@inheritdoc}
   */
  public function getBlockPrefix()
  {
      return 'appbundle_link';
  }
  </code></pre>
  
  <p>a part of Controler:</p>
  
  <pre><code>public function newAction(Request $request)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $categories = $em-&gt;getRepository('AppBundle:Category')-&gt;findAll();
      $subCategories = $em-&gt;getRepository('AppBundle:SubCategory')-&gt;findAll();
      $gestionCategorie = $this-&gt;container-&gt;get('app.categorie');
      $link = new Link();
  
      $repository = $this
          -&gt;getDoctrine()
          -&gt;getManager()
          -&gt;getRepository('AppBundle:Link');
  
      $category = $repository-&gt;findCategory();
      $subCategory = $repository-&gt;findSubCategory();
  
      $form = $this
          -&gt;get('form.factory')
          -&gt;create('AppBundle\Form\LinkType', $link)
  
          -&gt;add('categories', ChoiceType::class, array(
              //  on inverse les clés et valeurs
              'choices'   =&gt; array_flip($category),
              'label'     =&gt; "Catégorie",
              'attr'  =&gt; ['class' =&gt; 'form-control'],
          ))
          -&gt;add('sousCategories', ChoiceType::class, array(
              //  on inverse les clés et valeurs
              'choices'   =&gt; array_flip($subCategory),
              'label'     =&gt; "Sous-catégorie",
              'attr'  =&gt; ['class' =&gt; 'form-control'],
          ));
  
      $form-&gt;handleRequest($request);
  
      if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
  </code></pre>
  
  <p>If you have other questions, don't hesitate</p>