Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Closed
Labels
Milestone
Description
As per discussion on #symfony this evening, it should be documented somewhere that when you have a ManyToMany relationship, and you need the inverse to update the ORM model, you need to pass the by_reference option.
https://gist.github.com/3121916 is a good example of setting up this sort of relationship. Then in your form:
<?phpuseSymfony\Component\Form\AbstractType;useSymfony\Component\Form\FormBuilderInterface;useSymfony\Component\OptionsResolver\OptionsResolverInterface;class UserGroupTypeextends AbstractType{publicfunctionbuildForm(FormBuilderInterface$builder,array$options) {$builder ->add('users',null,array('label'=>'Users','by_reference' =>false))... ; }publicfunctionsetDefaultOptions(OptionsResolverInterface$resolver) {$resolver->setDefaults(array('data_class' =>'UserGroup' )); }publicfunctiongetName() {... }}