title: Symfony form category - subcategory
body: <p>I try to make a form with category and subcategory like the picture below :<a href="https://i.stack.imgur.com/gwzXr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gwzXr.png" alt="enter image description here"></a></p>
  
  <p>So, I made my form like that :</p>
  
  <pre><code>        -&gt;add('souscategorie', EntityType::class, array(
                                      'label' =&gt; false,
                                      'class' =&gt; 'App:souscategorie',
                                      'query_builder' =&gt; function(EntityRepository $er) {
                                          return $er-&gt;createQueryBuilder('souscategorie')
                                              -&gt;leftJoin('souscategorie.categorie', 'categorie')
                                              -&gt;addSelect('souscategorie')
                                              -&gt;addSelect('categorie')
                                          ;
                                      },
                                      'expanded'=&gt; true,
                                      'multiple'=&gt; true,
                                      'choice_label' =&gt; function($sousCategorie){
                                          return $sousCategorie-&gt;getCategorie()-&gt;getNom()." - ".$sousCategorie-&gt;getNom();
                                      },
                                      'group_by' =&gt; function($sousCategorie, $key, $value){
                                          return $sousCategorie-&gt;getCategorie()-&gt;getNom();
                                      }))
  </code></pre>
  
  <p>The result show all categories and subcategories concatenate.</p>
  
  <p>How to split categories and subcategories ?</p>
  
  <p>Thanks for your help ;)</p>