Form composition
//page
const form = useAppForm({
...formOpts,
onSubmit: async({value}) => {
const response= await submit(value)
if(response){
//other stuff
setResult(response)
toast("success")}
}
})And i have config formOpts file with types, zod and validation with another onSubmit
const formSchema = z.object({
...
})
export const formOpts = formOptions({
defaultValues: {
...
},
validators: {
onSubmit: formSchema,
},
})
And form component which is just form and fields
What is the best way people do forms in tanstack? I think about moving form validation from the page to custom hook that will return form, submit and result values