Manually adding argument to action in form before calling AshPhoenix.Form.submit
I'm using
AshPhoenix.Form
to handle creation of a resource in LIveView.
In my resource, I added this action:
That action now needs to receive a list of images which is a list of maps.
That list is created during the "submit" event after I consume images uploaded:
So, what I need now is to add the images
variable as the :images
argument of my :my_create
action to my form before calling AshPhoenix.Form.submit
.
Is there a way to do that?7 Replies
And then if you want to do it on submit (because that is when you have the images)
update_options seem to expect a function, not a keyword 🤔
oh, sorry
merge_options
Hmm, after calling merge_options the field prepare_source is still nil, I believe it should have that function now right?
🤔 right you are
Sorry about that, for now just do this
Hmm, submit is still returning an error saying that
:images
is required for some reason 🤔
I don't know why, but this worked if I add both when creating the form and when submitting:
Yeah, this makes sense, although its not ideal. The reason you need both is likely because
images
is a required argument
and so the initial form validation isn't valid without it