Form Events
Event handlers are functions or methods that are designed to respond to specific events or triggers within a software application. These events can be user interactions, system events, or changes in the application state. Event handlers play a crucial role in controlling the flow of an application and responding to various scenarios. Let's explore the benefits of event handlers in the context of the form's Data tab settings, whose current names are On Before Data Load (onBeforeDataLoad, formerly known as onInitialized), Prepare Submit Data (onPrepareSubmitData, formerly known as preparedValues), On Values Update (onValuesUpdate, formerly known as onUpdate), and On After Data Load (onAfterDataLoad, formerly known as onDataLoaded).
Older forms that still use the legacy names above are automatically migrated to the current names the next time they are opened, so they keep working without manual changes.
These events contain a standard list of variables that give you access to certain variables and functions facilitating the need to respond to various scenarios. Namely:
data- the form's current field valuesmomentfunction for DateTime operationsparentFormValuesinitialValuesmessage- toast notification functionalityform- the form instance, includingform.setFieldsValueandform.clearFieldsValuefor updating form datahttp- axios instance used to make http requests
On Before Data Load
Runs before the form starts loading its data, so you can prepare things the rest of the form depends on.
Prepare Submit Data
Allows customization or modification of form values right before submission.
On After Data Load
Runs once the form has finished loading and applying its data.
On Values Update
Responds to every change in the form field values.