Skip to content

fix: propagate shared context to nested forms in add_form and validate#472

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
nallwhy:fix/propagate-shared-context-in-add-form-and-validate`
May 13, 2026
Merged

fix: propagate shared context to nested forms in add_form and validate#472
zachdaniel merged 1 commit into
ash-project:mainfrom
nallwhy:fix/propagate-shared-context-in-add-form-and-validate`

Conversation

@nallwhy

@nallwhy nallwhy commented May 13, 2026

Copy link
Copy Markdown
Contributor

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

The previous fix (5db38dc) only threaded shared context through handle_forms. Nested forms created by add_form/3 and re-created during validate_nested_forms still called for_action without :context, so :shared context 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 a shared_context/1 helper used across handle_forms, validate_nested_forms, and do_add_form.

Copilot AI review requested due to automatic review settings May 13, 2026 01:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/1 helper to centralize filtering context down to :shared.
  • Threads shared context through validate_nested_forms/6 and do_add_form/6 nested for_action calls.
  • 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 zachdaniel merged commit b890bbf into ash-project:main May 13, 2026
27 of 29 checks passed
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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.

3 participants