I have three model tables: Checklists, Questions, and QuestionGroups.
Checklists hasMany Questions / Questions belongsTo Checklists.
Checklists hasMany QuestionGroups / QuestionGroups belongsTo Checklists.
Questions belongsTo QuestionGroups / QuestionGroups hasMany Questions.
There's a triangle of associations here.
The ChecklistsTable has the Duplicatable behavior added like this:
$this->addBehavior('Duplicatable.Duplicatable', [ 'contain' => [ 'Questions', 'QuestionGroups', 'Questions.QuestionGroups', ], ]);
When duplicating a checklist, everything works great except for the connection between Questions and QuestionGroups. The duplicated Questions still have their question_group_id set to the original QuestionGroup from the original Checklist; not the newly created QuestionGroups.
How can I get the Questions.question_group_id to be set to the newly created QuestionGroup.id?
I have three model tables: Checklists, Questions, and QuestionGroups.
Checklists hasMany Questions / Questions belongsTo Checklists.
Checklists hasMany QuestionGroups / QuestionGroups belongsTo Checklists.
Questions belongsTo QuestionGroups / QuestionGroups hasMany Questions.
There's a triangle of associations here.
The ChecklistsTable has the Duplicatable behavior added like this:
$this->addBehavior('Duplicatable.Duplicatable', [ 'contain' => [ 'Questions', 'QuestionGroups', 'Questions.QuestionGroups', ], ]);When duplicating a checklist, everything works great except for the connection between Questions and QuestionGroups. The duplicated Questions still have their question_group_id set to the original QuestionGroup from the original Checklist; not the newly created QuestionGroups.
How can I get the Questions.question_group_id to be set to the newly created QuestionGroup.id?