Catchable Fatal Error: Argument 1 passed to "...\FormType::__construct() must implement interface

Nicks

I am trying to call entityManager in formType. I don't get why this is not working.

FormType :

private $manager;

public function __construct(ObjectManager $manager)
{
    $this->manager = $manager;
}

Controller:

$form = $this->createForm(ProductsType::class, $products);

Services:

apx.form.type.product:
    class: ApxDev\UsersBundle\Form\ProductType
    arguments: ["@doctrine.orm.entity_manager"]
    tags:
        - { name: form.type }

Error:

Catchable Fatal Error: Argument 1 passed to MyBundle\Form\FormType::__construct() must implement interface Doctrine\Common\Persistence\ObjectManager, none given, called in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php on line 90 and defined

Cerad

Assuming your services.yml file is being loaded and that you copied pasted in the contents then you have a simple typo:

# services.yml
class: ApxDev\UsersBundle\Form\ProductType
should be
class: ApxDev\UsersBundle\Form\ProductsType

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Related Related

HotTag

Archive