Skip to content
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

Unable to Use Form's method. action, and encType. #132

Open
ratuspro opened this issue Dec 4, 2024 · 3 comments
Open

Unable to Use Form's method. action, and encType. #132

ratuspro opened this issue Dec 4, 2024 · 3 comments

Comments

@ratuspro
Copy link

ratuspro commented Dec 4, 2024

Hey,

I've been attempting to use Form's props to set up the action and method, but they always default to method="GET" and action="."
I've attempted to make it work with handleSubmit, but it seems that whenever handleSubmit is assigned to onSubmit, it does not work. However, when onSubmit is not defined, it seems to work. This issue seems to be related to the handleSubmit provided by useRemixForm.

After going through the test cases in the repo, particularly this, seems that submitConfig can be used to specify the action, method, and encType. After trying it, it works as expected.

As such, the expected behaviour of defining the action and method in the Form component while also assigning handleSubmit to its onSubmit prop does not work. Although I had problems with react router v7, it seems not to be the problem since the submitConfig attribute in useRemixForm make the Form work as intended.

I'm unsure if I'm missing any particular caveat, but let me know if this is an issue.

@AlemTuzlak
Copy link
Contributor

Can you create a minimum repro? I just tested out the form inheritance and it indeed does inherit from the form action and encType and method

@melanieseltzer
Copy link

melanieseltzer commented Dec 16, 2024

I'm also running into this with fetchers on remix-hook-form@5.1.1. Here's a minimal repo for my case.

I get this error when clicking submit on the form:

Error: {"status":405,"statusText":"Method Not Allowed","internal":true,"data":"Error: Route \"routes/_index\" does not have an action, but you are trying to submit to it. To fix this, please add an `action` function to the route","error":{}}

Uncomment the submitConfig and it works. Looks like it's not properly inheriting from the form component props and the action needs to be defined in the submitConfig too.

@ratuspro
Copy link
Author

In my situation, my projected relied on version "5.1.1" to handle non "react-router" remix apps. In that version, there seems to be a problem with handling the properties from the dom.

However, I've been migrating our app to react-router v7 with a newer version of remix-hook-form, and the issue is not relevant anymore.

Still, if compatibility is a must, perhaps a bugfix might be recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants