AshPhoenix potential bug with relationships
I have the following form:
I do get an error if the
number
or plane
field is missing, but I don't have any errors for the departure
, arrival
and alternate
fields.
All 3 of these fields have a similar relationship on my resource that looks like this:
If I inspect the form, I don't see any errors at all regarding those fields, as if they weren't attributes at all, but I do see the attributes data:
attributes: %{alternate: nil, arrival: nil, departure: nil, number: nil},
Shouldn't the form show errors about those fields being required?6 Replies
Ah, interesting. So the issue is that for
belongs_to
relationships we delay their validation until just before the action is submitted.
This is because manage_relationship
might set the value after the action starts.
But in retrospect, this doesn't really make sense. What we should do instead is only do that for things that have a manage_relationship
set up for them
I will add this to my list to fix.Nice thanks for the quick reply! 🙂
Okay, I've pushed some stuff to main that should resolve this.
I'm still poking around in some of my apps and making sure there aren't weird downstream consequences. If it proves to be troublesome than I will probably need to save it for a major release (its possible people were relying on this in a weird way).
Thank you Zach! However I pulled main and I don't see anything different 😦 Is it on AshPhoenix's main branch or Ash itself?
🤔 interesting
Its ash's main branch
is that what you pulled?
Nah I pulled AshPhoenix, that explains it 😄
Works perfectly 😁