我有这样的场景:
跟踪ManyToMany乐器
我以这种方式创建表单:
$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'.
我不明白为什么......
我在哪里做错了?
答案 0 :(得分:1)
这听起来非常明显,但错误不能说谎。检查Acme\DemoBundle\Entity\SoundtrackVersion
实体是否具有属性instruments
以及方法setInstruments()
和getInstruments()
。