Repeat form components with morphToMany delete previous data and add new data.

I have a user table and users may have different roles. Role could be added from form or other table action. Role can be Repeat form components with roles relationship. While I'm add through the create action then it works fine. But I made a table action add roles from the user table and show form with a repeat field role then it deleted old data and saved new data.
2 Replies
Asmit Nepali
Asmit Nepali3w ago
Any idea 💡
toeknee
toeknee3w ago
morphToMany does indeed remove and then add to avoid leaving legacy relationships etc otherwise you need to get them, check what exists, move out the ones that exist, thena add them.