我不知道为什么这不起作用:
->add('productSearchType', EntityType::class, array(
'label' => 'entity.text.product.product_search_number_type',
'class' => AC\ProductBundle\Entity\ProductSearchType::class,
'choice_label' => 'designation',
'expanded' => false,
'placeholder' =>
'entity.text.product.select_product_search_number_type',
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('e')
->orderBy('e.designation', 'ASC');
},
))
这是错误信息:
可捕获的致命错误:参数1传递到
Symfony的\桥\原则\表格\型号\ DoctrineType :: __结构()
必须实现接口Doctrine \ Common \ Persistence \ ManagerRegistry,
没有给出,在(...)\ src \ Symfony \ Component \ Form \ FormRegistry.php中调用 在第85行并定义(...)
答案 0 :(得分:0)
尝试像这样创建表单,以便表单工厂可以访问容器:
$form = $this->get('form.factory')
->create(VariantType::class, $entity, ['method' => 'POST'])
->getForm();