title: Instance of closure when i'm looking for an instance of entity in form symfony
body: <p>In a Symfony form, I have to add an instance of an Entity but I don't want to add all of the tuples of this entity in my form's choice. When I use <code>ChoiceType::class</code> I get this error:</p>
  <blockquote>
  <p>Expected argument of type &quot;App\Entity\Authorization or null&quot;,
  &quot;instance of Closure&quot; given at property path &quot;authorization&quot;.</p>
  </blockquote>
  <p>This is my form:</p>
  <pre><code>public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $options=[];
          $builder
              -&gt;add('authorization', ChoiceType::class, [
                  'choices' =&gt; [
                      'Intervenant' =&gt; function(?AuthorizationRepository $authoRepo){
                          $result = $authoRepo-&gt;findOneBy(['name'=&gt;'intervenant']);
                          return $result;
                      },
                      'Administrateur Structure' =&gt; function(?AuthorizationRepository $authoRepo) {
                          $result = $authoRepo-&gt;findOneBy(['name' =&gt; 'admin Structure']);
                          return $result;
                      }
                  ],
                  'label' =&gt; 'Choisir le type de demande',
                  ])
  
              -&gt;add('structure', EntityType::class, ['class'=&gt;Structure::class,
                  'choice_label'=&gt;'completeName'
                  ]);
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; ValidationAuthorization::class,
          ]);
      }
  </code></pre>
  <p>This is my controller:</p>
  <pre><code>public function authorization(Request $request, Users $user): Response
      {
          $valid = new ValidationAuthorization();
          $formAutho = $this-&gt;createForm(AuthorizationType::class, $valid);
          $formAutho-&gt;handleRequest($request);
  
          if ($formAutho-&gt;isSubmitted() &amp;&amp; $formAutho-&gt;isValid()) {
              $valid-&gt;setIsValide(false);
              $valid-&gt;setUser($user);
              $this-&gt;entityManager-&gt;persist($valid);
              $this-&gt;entityManager-&gt;flush();
  
              $this-&gt;addFlash('success', 'Votre demande a été prise en compte');
              return $this-&gt;redirectToRoute('users_index');
          }
          return $this-&gt;render('users/authorization.html.twig', [
              'formAutho' =&gt; $formAutho-&gt;createView(),
              'user' =&gt; $user,
          ]);
      } 
  </code></pre>