So, for some reason, anything I do to data in the beforeSave callback, though it works on single records, does not work when using saveMany.
What gives? If I do the following:
public function beforeSave() {
$this->data['foo'] = 'bar'
die($this->data);
}
I can see that in fact $this->data does DOES get changed, but saveMany just ignores it and saves the original data instead.
Make sure you include the model name when manipulating $this->data, e.g. $this->data[‘Event’][‘foo’] = bar. Be sure the method returns true as well or the save will fail.
Edit
I whipped up a quick example and it seems to be working for me, see the code below. My suspicion is that maybe you are calling saveMany incorrectly and passing it the whole $this->request->data object but it’s hard to guess without seeing your call as well.
View
Controller
Model