我有這樣一個場景:多對多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