`update_form` doesn't update params on root form
Im using the
AshPhoenix.Form.update_form function to update a subform of the root form.
If after the update_form I call a validate or update_params on the root form the params are reset to the values before the update_form call.
Since a code snippet says more than 1000 words:
I'm wondering whether this is a bug or if there's something I'm missing in the usage of update_form.6 Replies
so what is the value then, if not
changed@email.org?
I suspect something around only_touched? - what happens if you remove that?Its
example@email.org (set as the default when adding the form)
Removing only_touched? doesnt change anything
I mean it makes sense that the update_params overrides the values set by the update_form given that the update_form doesnt change the params on the root form
I've found this thread:
https://www.answeroverflow.com/m/1396883753443524788#solution-1396886969719459984
Which suggests validating again with params from the params function:
Which seems to work.
But then I run into new issues where the params cannot be cast into the correct type. For example When you have a Union type in a form its params value is a struct (%Ash.Union{})
The value in the raw_params is %{"value" => "value", "_union_type" => "type"} which could be cast into the paramsI thought I'd done something similar like this in the past - I didn't use
update_params, I had code like
Don't think it matters what you do to the form in the
update_form. It just doesnt update the params on the root form.well no, because you're updating the nested form, not the root form
Correct, it just doesn't update the params. There is
update_params if you want to update the params