Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Improvements around unlinking relationships #595

Merged
merged 10 commits into from
Sep 5, 2024

Conversation

duncanmcclean
Copy link
Member

Right now, when you "unlink" a related model using the Has Many fieldtype, it'll permanently delete that model. It has worked this way for as long as I can remember, for no good reason.

This pull request makes some changes to how "unlinking" relationships work in the Has Many fieldtype.

  • When the relationship_id column is nullable, instead of deleting the related model, it'll simply set the column to null.

  • When the relationship_id column is not nullable, it will continue to delete the related model, however it'll show a confirmation prompt before the model can be unlinked.

    CleanShot 2024-09-05 at 11 29 31

  • When the Has Many fieldtype is used for BelongsToMany relationships, it'll always "unlink" the relationship by deletng the row in the pivot table.

Closes #582.

@duncanmcclean duncanmcclean merged commit 9f55a1c into 7.x Sep 5, 2024
6 checks passed
@duncanmcclean duncanmcclean deleted the improvements-around-unlinking-relationships branch September 5, 2024 10:32
Copy link

github-actions bot commented Sep 5, 2024

Released as part of v7.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HasMany relationship: unlink deletes related resource
1 participant