This is an issue because the generated forms for your models override the doSave() method and call save*List() functions which are generated for each many to many relationship that exists on the model. Since the many 2 many relationships are saved by calling save() on the embedded form model object the many 2 many relationships are never updated. To fix the issue in our project I had to override the saveEmbeddedForms() method in BaseFormDoctrine?.class.php with the following code:
public function saveEmbeddedForms($con = null, $forms = null)
{
if (is_null($con))
{
$con = $this->getConnection();
}
if (is_null($forms))
{
$forms = $this->embeddedForms;
}
foreach ($forms as $key => $form)
{
if ($form instanceof sfFormDoctrine)
{
$form->bind($this->values[$key], $this->taintedValues[$key]);
$form->doSave($con);
$form->saveEmbeddedForms($con);
}
else
{
$this->saveEmbeddedForms($con, $form->getEmbeddedForms());
}
}
}
You can see I bind the data to the embedded form then call doSave(). I don't call save() b/c it would then wrap everything in more unnecessary transations.