<Formiz> component

Import

import { Formiz } from '@formiz/core'

Props

onSubmit(values)

Triggered when the form is submitted.

onValidSubmit(values)

Triggered when the form is valid and submitted.

onInvalidSubmit(values)

Triggered when the form is invalid and submitted.

onChange(values)

Triggered every time the form changes.
⚠️ This is triggered when each field is mounted.
ℹ️ Instead you can get values of the form with the useForm() hook.

onValid()

Triggered when the form is valid.
ℹ️ Instead you can get isValid value with the useForm() hook.

onInvalid()

Triggered when the form is invalid.
ℹ️ Instead you can get isValid value with the useForm() hook.

autoForm

Set to true to auto add a <form> element with auto onSubmit.
ℹ️ Instead you can get the submit() method with the useForm() hook and use it with your own <form> element.

connect

Allow you to connect your form with the useForm() hook.
See useForm() documentation for more details


Handle API errors

const myForm = useForm()
<Formiz
connect={myForm}
onValidSubmit={(values) => {
myForm.invalidateFields({
fieldName: 'Error message',
})
}}
/>
{/* Your fields here */}
</Formiz>