我有这样一个场景:多对多NULLABLE不允许
轨道多对多仪器
我创造这样的形式:
$builder
->add('instruments', 'entity_hidden', array(
'attr' => array('class' => 'one_req'),
'label' => 'form.instrument',
'translation_domain' => 'label',
'required' => false,
'class' => 'Acme\DemoBundle\Entity\Instrument'
))
“hidden_entity”是一个自定义的变压器因为你可以在这里找到:gist
虽然我认为这不是问题。
问题是,用户甚至可能不会选择任何仪器(例如其他指定的仪器,如"required" => false
)。
当我去拯救我返回此错误:
Neither the property 'instruments' nor one of the methods 'setInstruments()',
'__set()' or '__call()' exist and have public access in
class 'Acme\DemoBundle\Entity\SoundtrackVersion'.
我不明白为什么..
我在哪里做错了吗?
你确定在'Acme \ DemoBundle \ Entity \ SoundtrackVersion'中有一个'setInstruments'方法吗?确保你运行了'php app/console doctrine:generate:entities' – Touki
没有setInstrument不存在,但应该有! 是一个关系ManyToMany和教条:生成:实体不创建设置方法,但只添加方法。 然后我不会没有任何价值,我不明白为什么它必须使用一套方法.. – Lughino