-
Notifications
You must be signed in to change notification settings - Fork 959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use struct in Phoenix.HTML.Form.params? #3661
Comments
Hey @rapidfsub, the params of a Some helpful things you could do are:
|
@SteffenDE My question is "Is this allowed, or not recommended?" |
The current typespec doesn't allow it: https://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html#t:t/0 params: %{required(binary()) => term()}, Is this officially encouraged by Ash anywhere? |
No. But it is just possible to do. |
params: %{required(binary()) => term()}, @SteffenDE |
You're right. The spec actually allows the values in the params to be anything, but for nested form values, LiveView expects those to be maps with string keys as well. I don't think this is something want to change, so I'd encourage you to ensure that you pass nested parameters a maps with string keys too. |
In normal case, "the value of
^field_str
key inparams
map" would be a string or a map with string keys.But with
ash_phoenix
I can set it as a struct, i.e. Decimal.With struct value,
used_input?/1
always returns false, becausenested
is a map with only atom keys.Is it proper to assign struct in params? Then this could be a bug.
Or, is it not intended to assign struct in params?
The text was updated successfully, but these errors were encountered: