I'm trying to build an "Add an Event" page. You can add multiple "Schedules" - each of which will have calculations run on the date(s) / repeat options you set to create "Dates".
-Event hasMany Schedule
-Schedule hasMany Date
-Schedule belongsTo Event
-Date belongsTo Sched开发者_高级运维ule
The question is - how does the data need to be formatted and/or how to the field names need to read in order to be able to saveAll() the data so Date(s) are also saved. I have it currently working so it saves the Event and the Schedule... but I can't get it to also save the Date(s).
UPDATE: See answer marked as 'answer'. This answer is out of date.
It appears it's not possible according to this stackoverflow answer.
ie - have to do it manually, not in the same "saveAll()".
Actually, since CakePHP 2.1, you can do it with saveAll(). Doesn't matter the deep level you have within your models. Here you can see the new features.
http://book.cakephp.org/2.0/en/appendices/new-features-in-cakephp-2-1.html#model-saveall-model-saveassociated-model-validateassociated
saveAll
only works on models that are directly associated. From the CakePHP doc:
Saving related data with saveAll() will only work for directly associated models. If successful, last_insert_id()'s will be stored in the related models id field, i.e. $this->RelatedModel->id.
http://book.cakephp.org/view/1031/Saving-Your-Data
精彩评论