fix: propagate shared context to nested forms in add_form and validate#472
Merged
zachdaniel merged 1 commit intoMay 13, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes nested form context propagation so that only the parent form’s :shared context is preserved when nested forms are created or recreated through initial params, add_form/3, and validation.
Changes:
- Adds a
shared_context/1helper to centralize filtering context down to:shared. - Threads shared context through
validate_nested_forms/6anddo_add_form/6nestedfor_actioncalls. - Adds regression tests for initial params,
add_form, and validate-created nested forms.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/ash_phoenix/form/form.ex |
Propagates filtered shared context to nested forms across form handling, validation, and add-form paths. |
test/form_test.exs |
Adds/renames tests verifying only :shared context reaches nested forms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zachdaniel
approved these changes
May 13, 2026
Contributor
|
🚀 Thank you for your contribution! 🚀 |
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.
Contributor checklist
Leave anything that you believe does not apply unchecked.
The previous fix (5db38dc) only threaded shared context through handle_forms. Nested forms created by
add_form/3and re-created during validate_nested_forms still calledfor_actionwithout:context, so:sharedcontext was lost whenever a form was modified after creation.Propagate shared context in both code paths, and extract the
Map.take(context, [:shared])filter into ashared_context/1helper used across handle_forms, validate_nested_forms, and do_add_form.