Custom formType with Symfony 7

  Kiến thức lập trình

I try to create a custom FormType. I need to use external service and i want to use friendly autowiring of the depedency injection.

...
class HiddenDocumentType extends AbstractType
{    
         public function __construct(private ManagerRegistry $registry) {}
...

When i use it, i have this error :

Too few arguments to function AppFormTypeHiddenDocumentType::__construct(), 0 passed in /var/www/html/vendor/symfony/form/FormRegistry.php on line 78 and exactly 1 expected

I don’t understand why the “vendor/symfony/form/FormRegistry.php” try to create new instance of class instead of using the depency injection ?

Error stack

Thank’s you

New contributor

Thomas Lecarpentier is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT