fix: preserve manage_relationship changes for AshPhoenix nested forms#88
Open
BlitzBanana wants to merge 1 commit intoash-project:mainfrom
Open
fix: preserve manage_relationship changes for AshPhoenix nested forms#88BlitzBanana wants to merge 1 commit intoash-project:mainfrom
BlitzBanana wants to merge 1 commit intoash-project:mainfrom
Conversation
When AshEvents wraps actions, all changes get wrapped inside ReplayChangeWrapper, making them invisible to AshPhoenix's find_manage_change/2. This causes AshPhoenix.Form.NoFormConfigured errors when using `forms: [auto?: true]` with `inputs_for`. Append copies of manage_relationship changes with `ignore?: true` (like suggested by @zachdaniel in ash-project#87) to the wrapped action's changes list so AshPhoenix can detect them for form generation while the actual relationship management is still handled by the wrapped original.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: I was having an issue using AshPhoenix auto forms with AshEvent, and tracked down the issue to the way AshEvent wrap actions, hiding relationship changes from AshPhoenix. Raising
AshPhoenix.Form.NoFormConfiguredwhen trying to access a nested form.Solution: As suggested by @zachdaniel in #87, I updated lib/events/transformers/wrap_actions.ex to append a copy of relationship changes to the wrapper itself, but with the
ignore?: trueoption. So AshPhoenix can detect them, but the actual execution stays in the wrapped original action.I took the liberty to add a unit test for this specific issue.
Contributor checklist
Leave anything that you believe does not apply unchecked.