onChange | function | (optional) Will be called when a value of a field was changed by the user, with the data set (including the changed value) as argument. When an async function is provided, it will show an indicator on the current label during a field change. Related props: minimumAsyncBehaviorTime and asyncSubmitTimeout. You can return an error or an object with these keys { info: 'Info message', warning: 'Warning message', error: Error('My error') } as const in addition to { success: 'saved' } indicate the field was saved. Will emit unvalidated by default and validated when an async function is provided (like onSubmit). The second parameter is an object containing the filterData, resetForm and clearData functions. |
onPathChange | function | (optional) Will be called when a value of a field was changed by the user, with the path (JSON Pointer) and new value as arguments. Can be an async function. Will emit unvalidated by default and validated when onChange is an async function. |
onSubmit | function | (optional) Will be called (on validation success) when the user submit the form (i.e by clicking a Form.SubmitButton component inside), with the data set as argument. When an async function is provided, it will show an indicator on the submit button during the form submission. All form elements will be disabled during the submit. The indicator will be shown for minimum 1 second. Related props: minimumAsyncBehaviorTime and asyncSubmitTimeout. You can return an error or an object with these keys { status: 'pending', info: 'Info message', warning: 'Warning message', error: Error('My error') } as const to be shown in a FormStatus. Will only emit when every validation has passed. The second parameter is an object containing the filterData, reduceToVisibleFields, transformData, resetForm and clearData functions. |
onSubmitRequest | function | (optional) Will be called when the user tries to submit, but errors stop the data from being submitted. The first parameter is an object containing the getErrors method, returning an array with field errors. Each error object contains the path, error and props of the field. You can use this to log the errors before the form is submitted. |
onSubmitComplete | function | (optional) Will be called after onSubmit has finished and had no errors. It supports the same return values as onSubmit and will be merged together. |
onClear | function | (optional) Will be called when the form is cleared via Form.clearData or via the onSubmit event (or onCommit) argument { clearData }. |