如何在集合字段中处理实体表单选择:Symfony

时间:2015-12-01 14:07:05

标签: php forms symfony

我想使用多个'实体'字段作为集合字段类型:

class AddBrand extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('Name', 'text', array('label' => 'Enter brand name'))
            ->add('Models', 'collection', array
            (
                'type' => 'entity',
                'options' => array
                (
                    'class' => 'Baka\MainBundle\Entity\Model',
                    'choice_label' => 'Name'
                )
            ));
    }

但我无法确定是否可以指定&#39;实体&#39;字段选项(如果未指定任何选项,则<#39; 所需选项&#34;类&#34;缺少&#39;异常被抛出)。品牌与OneToMany有关系。

0 个答案:

没有答案