【发布时间】:2017-04-09 02:13:15
【问题描述】:
我是奏鸣曲的初学者,我不明白如何使用 2 个表 Oraganizations(one) 和 structures_type(many) 在一对多(下拉列表)中做 choicetype。
我在奏鸣曲文档中找不到任何东西。我使用奏鸣曲 2.3 和 symfony 2.8。
如果有人可以帮助我解决这个问题。这是代码:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('structurestypes', EntityType::class, array(
'class' => 'HandissimoBundle:StucturesTypes',
'choice_label' => 'structurestype',
'label' => 'Type de structure',
'expanded' => true,
'multiple' => true,
'by_reference' => true
));
}
【问题讨论】:
-
这与任何其他 Symfony 表单完全相同。查看此页面:symfony.com/doc/current/reference/forms/types/entity.html
标签: symfony relationship one-to-many sonata-admin sonata