Use with a Resource Route #248
-
I have a resource route with a simple POST action: // app/routes/newsletter.ts
export const Validator = withZod(
z.object({ email: z.string() })
)
export async function action({ request }) {
const fieldValues = await Validator.validate(await request.formData())
if (fieldValues.error) {
// here's the problem:
return validationError(fieldValues.error)
}
return redirectBackOrHome()
}
I can do this: if (fieldValues.error) {
return redirectBackOrHome()
} but then I lose all the error messages from remix-validated-form. I can save them off via a Is there a good pattern for this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi! I believe you can achieve this with |
Beta Was this translation helpful? Give feedback.
Hi!
I believe you can achieve this with
useFetcher
and thefetcher prop
on theValidatedForm
.