I have the following output which I need to be inserted in the database:
Array
(
[Test] => Array
(
)
[Question] => Array
(
[0] => Array
(
[category_id] => 3
[answer_style_id] => 2
[Answer] => Array
(
[0] => Array
(
[capital_category_id] => 14
[correct] => 1
)
...
...
Briefly, each Test hasMany Questions, and each Question hasMany Answer, with each associated model having a foreign key which need to be set by Cake (each Question has a test_id, and each Answer has a question_id).
The problem is that when I $this->Test->saveAll($data);
, only the Test and the Questions get saved, not the answers.
How can I save all data, with Cake automagically setting the foreign key for each associated model?
Thank you!