From 3aef90108e22cc028cda80d0e85f755276c0a75e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kaiser Date: Tue, 25 Oct 2022 18:01:17 +0200 Subject: [PATCH] [no ci] [Doc] Document form validation mode --- docs/Validation.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/Validation.md b/docs/Validation.md index 64e21ef1ad3..425edba5df7 100644 --- a/docs/Validation.md +++ b/docs/Validation.md @@ -14,6 +14,22 @@ React-admin relies on [react-hook-form](https://react-hook-form.com/) for the va You can’t use both form level validation and input level validation - this is a `react-hook-form` limitation. +## Validation Mode + +By default, the validation mode is `onSubmit`, and the re-validation mode is `onChange`. + +Since [`
`](./Form.md) actually passes all additional props to react-hook-form's [`useForm` hook](https://react-hook-form.com/api/useform/), this can easily be changed by setting the `mode` and `reValidateMode` props. + +```jsx +export const UserCreate = () => ( + + + + + +); +``` + ## Global Validation The value of the form `validate` prop must be a function taking the record as input, and returning an object with error messages indexed by field. For instance: