【发布时间】:2016-06-26 15:36:54
【问题描述】:
我有一个表单类作为(服务),我使用entity type 选择一篇文章。
在 Symfony 2 中这有效:
$builder
->add('article', EntityType::class,
array(
'em' => $this->em,
'class' => 'MyBundle\Entity\Article',
'query_builder' => function ($em) {
return $em->createQueryBuilder('a')
->where('a.active = 1');
},
'choice_label' => 'name')
)
但在 Symfony3 中出现错误:
Neither the property "article" nor one of the methods ...
我的问题是文章没有属性article。当我将文章重命名为名称时
->add('name', ...`
请问如何将文章实体传递给表单?
【问题讨论】:
-
向我们展示连接到该表单的实体。
-
您希望使用该字段填充的数据是什么? (
$form->getData()的结果)
标签: php forms class symfony entity