-
Notifications
You must be signed in to change notification settings - Fork 0
Context Events
Dispatched every time the form is about to be submitted. Accepts promise as a handler. Useful if you want, for example, perform additional validation or value changes just before sending the form.
- isPristine:
T.object
- true if no input changed from its original state - errors:
T.object
- list of errors for the form - warnings:
T.object
- list of warnings for the form - values:
T.object
- list of values for the form
undefined || Object
Event handler can return an object with new data for specific input. It will ovewrite form data before form is submitted, however will not affect the specific input.
{
inputName: T.string,
errors: T.object,
warnings: T.object,
value: T.any,
}
If errors property is not empty, form submitting will be interrupted.
const handleOnFormSubmit = async ({
values,
errors,
warnings,
isPristine,
}) => {
// event handler body
}
this.context.listenTo('onFormSubmit', handleOnFormSubmit)
Dispatched every time the form data is updated. For example when any of the input is changed (onChange event). Also during form submission as it can be changed for example via onFormSubmit
event.
- errors:
T.object
- list of errors for the form - warnings:
T.object
- list of warnings for the form - isPristine:
T.bool
- true if no input changed from its original state - isSubmitting:
T.bool
- true if form is being submiting - isValid:
T.bool
- true if there is no errors in the form - isValidating:
T.bool
- true if form is currently validating
undefined
const handleOnFormUpdate = ({
errors,
warnings,
isPristine,
isSubmitting,
isValid,
isValidating,
}) => {
// event handler body
}
this.context.listenTo('onFormUpdate', handleOnFormUpdate)
Dispatched every time an input finished its asynchronous validation.
- inputName:
T.string
- Name of the input that finished its validation - message:
T.string
- If validation fails, this property contains error message returned by validation method
undefined
const handleOnAfterAsyncValidation = ({ inputName, message }) => {
// event handler body
}
this.context.listenTo('onAfterAsyncValidation', handleOnAfterAsyncValidation)
Dispatched every time an input is going to perform its asynchronous validation.
- inputName:
T.string
- Name of the input that finished its validation - value:
T.any
- Value of the input that will be validated
undefined
const handleOnBeforeAsyncValidation = ({ inputName, value }) => {
// event handler body
}
this.context.listenTo('onBeforeAsyncValidation', handleOnBeforeAsyncValidation)
Dispatched every time an input looses its focus
- inputName:
T.string
- Name of the input that lost his focus - value:
T.any
- Value of the input - isValid:
T.bool
- True if there is no errors - errors:
T.object
- List of input errors - warnings:
T.object
- List of input warnings
undefined
const handleOnInputBlur = ({
inputName,
value,
isValid,
errors,
warnings,
}) => {
// event handler body
}
this.context.listenTo('onInputBlur', handleOnInputBlur)
The same behaviour as in onInputBlur
event except it is dispatched every time the input value is changed.