I have a form being submitted via ajax. In response to that data being submitted, my model actively deletes all associated records, then assigns new records to be saved. This process is paraphrased below:
$this->db->begin(); $TCA = TCA::findFirst(...): $TCA->AGPA->delete(); $new_agpa = [ new AGPA(...), new AGPA(...) ]; $TCA->AGPA = $new_agpa; $TCA->save(); $this->db->commit();
For reasons unknown to me, I can submit identical POST data 2 times in a row, and the 1st POST can result in no new AGPA records being created, but the second POST will properly delete old records and create new ones. Or vice versa. Or not - sometimes the behaviour is the same.
The POST data is identical, so the code path should be the same too. I'm at a loss as to why or how there is EVER a time where new AGPA records aren't added.