I am having problems with saving data with associated. The problem is that i'm do thing on AfterSave and the associations are triggering the AfterSave before the principal entity($toSave). This is normal? It's like first save the associations then the principal entity. Is a way of changing the order of saving? Makes sense?
$toSave = $this->{MODEL_NAME}->patchEntity($toSave, $postData, ['associated' => ['SomeAssociation']]);
if ($this->{MODEL_NAME}->save($toSave)) {
}
Version: Cakephp 4.x
Thank you.