seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
652 stars 13 forks source link

Unable to retrieve name and value of button after form submission #64

Closed netdesignr closed 1 year ago

netdesignr commented 1 year ago

Hi,

I use remix-forms with domain-functions in my project and I would like to find out how to retrieve the form button name and value after form submission. I have to deal with multiple forms on the same page and to avoid the action to run for the whole code i need to track down the button that was pressed.

With plain Remix you can:

 let formData = await request.formData();
 let intent = formData.get("intent");

 <button type="submit" name="intent" value="update">

I can't seem to be able to replicate the similar effect using remix-forms and domain-functions

The only data I can see using await inputFromForm is

{
  success: true,
  data: undefined,
  errors: [],
  inputErrors: [],
  environmentErrors: []
}

Can someone please advice?

Thanks a lot! MIhai

gustavoguichard commented 1 year ago

Hey @netdesignr ! What if you log the results of inputFromForm prior to sending it into the domain function?

netdesignr commented 1 year ago

Hi @gustavoguichard I tried it and I get an object with the field name and values. Unfortunately the button name and value is still no in there...

gustavoguichard commented 1 year ago

Ok @netdesignr that is really weird, I'd expect at least { intent: "value" } in that object.

Is there a way you could share the code with us so we investigate further if this is a DF bug?

I've done something similar already and never faced that kind of bug. Let's see if there's anything missing;)

danielweinmann commented 1 year ago

This is a remix-forms bug. I just created the issue above to track it there :)

Thanks for catching it, @netdesignr o/

netdesignr commented 1 year ago

Thanks a lot @danielweinmann. Unfortunately I would not have been able to share the whole code but I went step by step trough Remix and Domain Functions docs and could not find a way to it.