'Symfony 5 Could not load type "App\Controller\EntityType": class does not exist

I have a problem when I'm trying to create an EntityType field in my Symfony5 form type.

This is the piece of code from the official EntityType reference in Symfony5 documentation:

use App\Entity\User;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
// ...

$builder->add('users', EntityType::class, [
    'class' => User::class,
    'choice_label' => 'username',
]);

and this is my version

use App\Entity\Famille;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
...
$builder
    ->add('fam_code', EntityType::class, [
          'class' => Famille::class,
          'placeholder' => 'Choisir une famille',
          'choice_label' => 'fam_libelle_f',
          'required' => 'true'
          ])
...);

Going back to the browser I'm getting

Could not load type "App\Controller\EntityType": class does not exist.

I didn't get this error when I created a form in the controller directly but when I tried to Create a Form Class it showed up and I don't know why.

Do I need to get some additional extensions for this field type?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source