Ash FrameworkAF
Ash Framework3y ago
16 replies
Robert Graff

Setting defaults for a form input that is an argument and not an attribute?

I have an update action that takes an argument. In the form for this action, I need to set the default value for the form input. The default value is dependent on the current state of the resource being updated.

I explored using the
default
option for an action argument; however, It accepts a zero-argument function, so there's no way to get the resource being updated.

I explored using the prepare_params option for
AshPhoenix.Form.for_update
but I couldn't find any examples. It's arrity 2 and receives the params but is only called when the form is validated or submitted.


Side quest(ion): what's the difference between prepare_params and transform_params if they're both called only on validate and submit?
Was this page helpful?