Lughino
Lughino

Reputation: 4118

ManyToMany nullable not allowed

I have a scenario like this:

tracks ManyToMany instruments

I create the form in this way:

$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" is given by a custom transformer that you can find here: gist

although I believe that is not the problem.

The problem is that the user may not even choose any instrument (such asamong other specified with "required" => false).

When I go to save my returns this error:

Neither the property 'instruments' nor one of the methods 'setInstruments()',
'__set()' or '__call()' exist and have public access in 
class 'Acme\DemoBundle\Entity\SoundtrackVersion'.

I do not understand why ..

Where am I doing wrong?

Upvotes: 0

Views: 955

Answers (1)

Alexey B.
Alexey B.

Reputation: 12033

It sounds very obvious, but error can not lie. Check that Acme\DemoBundle\Entity\SoundtrackVersion entity has property instruments and methods setInstruments() and getInstruments().

Upvotes: 1

Related Questions