Skip to content

fix: preserve manage_relationship changes for AshPhoenix nested forms#88

Open
BlitzBanana wants to merge 1 commit intoash-project:mainfrom
BlitzBanana:main
Open

fix: preserve manage_relationship changes for AshPhoenix nested forms#88
BlitzBanana wants to merge 1 commit intoash-project:mainfrom
BlitzBanana:main

Conversation

@BlitzBanana
Copy link
Copy Markdown

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.NoFormConfigured when 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?: true option. 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.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

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.
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.

1 participant