Closed
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:
<?php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class UserGroupType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('users', null, array('label'=>'Users', 'by_reference' => false))
...
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'UserGroup'
));
}
public function getName()
{
...
}
}