Doctrine ORM put null to relation field when write persisting #7588

Closed
nkt opened this Issue Apr 7, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

nkt commented Apr 7, 2013

There is my bundle, for more details:
https://github.com/hell0w0rd/bad-doctrine-entities
what am I doing wrong?

Contributor

nkt commented Apr 7, 2013

Problem can be solved if change the code, but it looks like a crutch:

$post = $form->getData()->setAddDate();
$em = $this->getDoctrine()->getManager();
$em->persist($post);
foreach($post->getDogs() as $dog) {
    $dog->setPost($post);
}
$em->flush();
Member

stof commented Apr 7, 2013

@hell0w0rd your Post::addDog method should take care of updating the owning side of the relation (by calling $dog->setPost($this), as Doctrine only considers the owning side (which is documented).

I'm closing this ticket as it is not a bug in Symfony (it is not even related to Symfony itself)

stof closed this Apr 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment