[Flow] Persistence of many to many relation
Rik Willems
rik at metmeer.nl
Sat Mar 29 14:07:47 CET 2014
Hi Christian,
Thanks for this hint. I ended up with this on the inverse side:
/**
* @param \Doctrine\Common\Collections\Collection $questions
* @return void
*/
public function setQuestions(\Doctrine\Common\Collections\Collection
$questions) {
// Remove all current questions
foreach ( $this->getQuestions() as $question ) {
$question->removeQuestionset($this);
}
// Set all new questions
foreach ( $questions as $question) {
$question->addQuestionset($this);
}
}
I expected this to work out of the box. Is there a reason why this is
not the case? Complex, not desired or something else?
Cheers!
Christian Müller schreef op 29-03-14 11:48:
> you need to take care about the owning side of the relation. Doctrine
> expects to always have a owning side for a relation and saving only
> works from that side. You can call the setter of the owning side in the
> other model if you need it to work transparently on both sides.
>
> Cheers,
> Christian
More information about the Flow
mailing list