OBS: I decided to open a answered question here because I have seen so many posts in Reddit and Github about submitting a form with shadcnui/react-hook-form in a Remix app.
I had an issue building a form with Remix and shadcn/ui (which uses react-hook-form) and I just solved it after hours.
To build the form, I followed these pages:
The problem was happening when I was submitting the form, not receiving any logs that I put in some sections of my code.
I checked other cases and tried some things to resolve it:
- changing form
onSubmit
attribute to various structures - verified if some fields were not “registered” in form (I added the UI components, that are registered by itself)
- verified any validation errors that could not be showed in screen.
- added
field
values (fromrender
attribute in my Switch component from shadcn, like that:
<Switch
checked={field.value}
onCheckedChange={field.onChange}
name={field.name}
ref={field.ref}
disabled={field.disabled}
onBlur={field.onBlur}
/>