How can I show all validation errors (including nested) at once?
I'm using manage_relationship/4 in a top-level action that accepts nested fields via arguments. Right now, the nested validation errors only show after the top-level data is valid. Is there a way to surface all validation errors (parent + nested) simultaneously? I'd like users to see everything in one go
Solution:Jump to solution
If you have time to make a PR, what needs to happen is something like this:
```elixir
form
|> AshPhoenix.Form.raw_errors(for_path: :all)...
17 Replies
🤔 it should show validation errors for all of them, that might be a bug
How are you setting up your forms?
Might need a reproduction for this one
Hope that can help
The errors on the top level of the form aren't all the errors
AshPhoenix.Form.errors(form, for_path: :all)
I'm using Inertia, I'm just passing down the errors I receive from executing the action
Ah, okay so that may be an issue with our protocol implementation then
Please open a bug on
ash_phoenix
GitHub
Nested validation errors only show after parent is valid · Issue #...
Code of Conduct I agree to follow this project's Code of Conduct AI Policy I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue. Versions Er...
assign_errors is the inertia helper right?
This code is the problem:
https://github.com/ash-project/ash_phoenix/blob/v2.3.12/lib/ash_phoenix/inertia/error.ex#L88
GitHub
ash_phoenix/lib/ash_phoenix/inertia/error.ex at v2.3.12 · ash-proj...
Utilities for integrating Ash and Phoenix. Contribute to ash-project/ash_phoenix development by creating an account on GitHub.
Solution
If you have time to make a PR, what needs to happen is something like this:
That's right
If you don't have time to make a PR mind copying my comments just now? I'm mega slammed rn
like copying into hte issue you opened I mean
not sure when I'll get to the fix
Happy to open my first PR but I'm a bit confused about the solution, where is the
form
variable coming from? Should I simply paste the code you provided? I'm a bit of a newbie to all this 😅It's that first argument to that function I linked
We're pattern matching just the top level errors
But yeah pretty much paste that code in there and change the pattern matched var to just "form"
Feel free to get it started and if you need help I can help on your PR 🙂
Okay I'll get to it as soon as I can, probably in a couple of hours. I'll let you know!
Hey Zach. I'm working on it, I modified the function at line 88
There is a problem though:
And a couple of tests are failing
Ah, right
Change it to
%AshPhoenix.Form{} = form
So that it only matches that function head when the first argument is a form 😄GitHub
fix: ensure nested form errors are included by joangavelan · Pull ...
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
...
Yee haha, that wasn't so difficult (when you're told what to do Lol)
Hope that helps