我正在尝试在formType
中调用entityManager
,但不知道为什么它无法正常工作。
FormType
:
private $manager;
public function __construct(ObjectManager $manager)
{
$this->manager = $manager;
}
控制器:
$form = $this->createForm(ProductsType::class, $products);
服务:
apx.form.type.product:
class: ApxDev\UsersBundle\Form\ProductType
arguments: ["@doctrine.orm.entity_manager"]
tags:
- { name: form.type }
错误:
可捕获的致命错误: MyBundle\Form\FormType::__construct() 的参数1必须实现 Doctrine\Common\Persistence\ObjectManager 接口,但未给出任何参数,调用位置为 vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php 的第90行,定义位置为xxx