Skip to content

Duplicate association on associated table #50

@OneHatRepo

Description

@OneHatRepo

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions