Open jmunozz opened 3 months ago
This is correct. I spent a lot of time tracking the issue why my formdata received on server was always empty object. This fixed the issue. Thanks @jmunozz
Hello @diwakersurya
Beware. My solution ends up not using the formRef
.
The action is simply call in the onSubmit
callback, not through the action attribute.
This does not change a lot, except...
There is one downside to that:
Some hooks that follows the status of the form through the action attribute are not working:
https://fr.react.dev/reference/react-dom/hooks/useFormStatus
Hi Thanks for your work ! I noticed that the from html object can be unsync with the react-hook-form object. In my case I use a form field that is passed to the form as a default value but cannot be modified by the user.
Then I render 2 form fields
When submitting the form. The html form has no knowledge of the "someIHiddenId" field. This part fails:
Instead I rather use the value returned by form.handleSubmit (an object) and convert it to formData.