Skip to content

How to automatically submit form once all Form fields are valid #3758

Answered by logaretm
y3hhhhhh asked this question in Q&A
Discussion options

You must be logged in to vote

I converted this to a discussion since it is more of a question than an issue.

Is there Form metadata (in the example below) I can access outside of the template tags

You should use the useForm composition function instead of the Form component for that purpose (you can still use <Field> component). Check the docs here.

 function setup () {
    const schema = yup.object({
      fullName: yup.string().required().label('Full Name')
    })

    const { meta } = useForm({ validationSchema: schema });

    return {
      meta,
      schema
    }
  },

Then you are free to watch the meta.valid and trigger a submit manually.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@y3hhhhhh
Comment options

Answer selected by y3hhhhhh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3755 on April 28, 2022 10:49.