-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
[help] Using remix-hook-form in a component (not a route) #125
Comments
you can pass in a custom fetcher and it will submit to that fetcher instead of the current route, I think that would allow you to submit anywhere? |
hey @AlemTuzlak in a similar vain how would I submit a form that is in a custom component in a route? |
if it's a custom component submitting to the current route, you don't need anything else other than the hook, otherwise if it's submitting to a different route, again, a custom fetcher will do! |
You mean the Minimal example of what my structure looks like // File 1 route
export default function RoutePage(){
return (
<CustomForm />
)
} //custom form component
export default function CustomForm() {
const remixForm = useRemixForm<zod.infer<typeof schema>>({
mode: 'onSubmit',
resolver: resolver,
})
return (
<FormProvider {...remixForm}>
<Form method="POST" onSubmit={remixForm.handleSubmit}>
<input name="cost" />
</Form>
<FormProvider>
) |
yes, but the reason it doesn't work in your case is because you're using the <Form element there iwthout the action prop, either set it to the current route or set it in the submitConfig of the hook |
@AlemTuzlak thank you that solved my issue. Great job on the yt videos and this library. |
@AlemTuzlak Thank you! |
Hi,
How would yo go about linking up a form within a modal that is not technically part of any route, thus cannot POST directly?
Is it possible to choose a target route manually that could handle the form submission?
Also, is it possible to fall back to regular client side validation? All my shadcn Form components depend on Remix Hook Form context and it would be nice to have an option for fallback, in case server side handling is not available.
Thanks for any hints!
The text was updated successfully, but these errors were encountered: