I have an preUpdate Eventlistener on an Entitychild in my embedded Form.
I can change the attribute related to my entity:
public function preUpdate(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
$em = $eventArgs->getEntityManager();
if ($entity instanceof AOSupplierReference) {
if ($eventArgs->hasChangedField('amount')) {
$entity->setConfirmed(false);
}
}
}
But now I have to change an attribute of the parent Entity, this don't work in my preUpdate event:
$entity->getPurchaseOrder()->setStatus(4);
only the $entity->setConfirmed(false) changes.
You can't update a related entity in a preUpdate listener:
See the documentation.