arno
arno

Reputation: 823

Symfony cascade update to a parent relation

I have a parent class A with relation oneToMany to class B (cascade persist)

I want to update A when B is updated (in a classic form/controller).

my problem is when I do something like this in B

$thisB->getParentA()->updateStuff()

the A modifications arent persisted... i dont know how to deal with it.

Upvotes: 1

Views: 1359

Answers (1)

Goran Jurić
Goran Jurić

Reputation: 1839

Take a look at this answer. Your B entity is probably not the owning side of the relation so it is not checked.

From the docs:

Doctrine will only check the owning side of an association for changes.

OneToMany is always the inverse side of a bidirectional association.

So you should probably call EntityManager::persist() on A to get it working.

Upvotes: 1

Related Questions