Replicate with relationship repeater updates original relation records but doesn't create new ones
Pretty much everything in the title.
Replicating an
invoice
, showing the resource form in the replicate modal. When updating the repeating items
, the form will update the original items instead of creating new ones. We also can't create the new items
in the after
method, as the items
are not present in the provided $data
.
Any idea how to achieve that, or should we open an issue?7 Replies
You will need to adjust the replicate functionality. To first replicate the record, then replace the relationships with the updated id of the record
Thanks for the answer.
My goal is to not touch the current records, but to create new ones.
By submitting the action, the original relationship items are updated, but not created at all.
Correct, so you need to adjust the action. Please provide the code you are using and I'll tell you how to adjust it so it doesn't update. It sounds like you are not using the replciate functionality correctly.
Pretty basic actually:
And the form contains the repeater
That looks generally ok, you need to look into the replicateAction because if sounds like you have possibly assigned the relationships to record and the record values are just copying across and what you need to do is also replicate those too.
gm
@toeknee not sure to have understood. When looking at the executed queries, we clearly see that:
- A query is made to update the previous items (children). I think it's not linked to the ReplicateAction, but the Repeater.
- No new items are created. The new invoice (parent) has no items at all.