select relationship
Resource relevant parts
In live view form_component i have form where i show select to select relationship
Input component
I dont understand why but selects does not hold their selected value. I can select one, but once i select other first looses value. For plain string value
AshPhoenix.Form.value(f, field)
returns correct input value, but for selects not.
Unrelated: for errors i had to do: AshPhoenix.Form.errors(f, format: :simple, for_path: [])[field]
, because AshPhoenix.Form.errors(f, format: :simple)
returned %{[] => %{key => value}}
If some relevant info is missing please let me know, i will provide it.9 Replies
can I see your entire validate callback?
🤔 from what I can see so far it looks correct to me.
Are there any errors on the form after validating?
IO.inspect(AshPhoenix.Form.errors(form, for_path: :all))
Any errors?
Are there any errors on the form after validating? IO.inspect(AshPhoenix.Form.errors(form, for_path: :all))
%{[] => [paid_at: "is required", amount: "is required"]}
I found "solution"
It seems that defaults does not add ability to populate relations.
Now IO.inspect(AshPhoenix.Form.errors(form, for_path: :all))
prints
As we can see it now has correct errors for related ids as well. Im not sure if this is intended behaviour of defaults or not. I would argue that defaults [:create, :update], should be able to populate relationship ids as well.Ah, I see what you mean
The arguments won't actually do it either
you have to do something with arguments to make them do something
but in your case:
thats what you want
How to mark as sloved? 😄
You can right click on the channel and tag it with solved
but I'll do it 😄