Form Events

We created the Lifecycle page in this documentation with the purpose of explaining the process of actions added on the form fields and to provide some understanding regarding the life cycle of Action Form.

To sum up, there are three Form Events, On Preinit, On Init and On Validation Failed, besides them, as action event can also be considered the On Click Handlers from the buttons.

event

When an action is set on Preinit Event, they are executed in the order you specify before form fields get initialized. Use this event to load data on which the fields depend on. Note that contextual data generated by these actions will NOT persist. So for example, you can use the context tokens in Conditions of controls or in their default values, but you can’t use them in the Condition of the Actions attached to buttons, because they will be executed later when the user clicks the button. You’ll need to add the relevant actions to the button to load data in that context too.

If there are actions set on Init Event, they get executed in the order you specify after the form fields have been initialized with a value. At this stage it’s safe to reference fields by their [FieldID] token to get their values. Note that contextual data generated by these actions will NOT persist.

Here’s an example on how to use the On Init section for the Form State actions:

  1. on your form add two buttons;

  2. on first button, add On Click Handler the Save State action with a key, let’s say key1 and with Save Location set to Server Session;

  3. on the second button, add On Click Handler the Save State action with the same key key1 and with Save Location set to Browser Cookies;

  4. go on Form Events On Init section and add Load State action on which you have to use the key used on the buttons in Save State actions, key1, and as Storage Location select the option “Any”.

These steps have the purpose to make the ActionFrom look first in Server Session, then in Browser Cookies.

The On Validation Failed event defines a list of actions to be executed when validation fails. Note that this can be handled per form or overridden for a specific server validator. The actions will be executed in the order you specify here. Click here to see a tutorial on an older version of Action Form where we provide some samples of how this event works.

And regarding the last event, On Submit, this event is used by adding actions on the button fields, on the click handlers - for more details, read the Form Actions sub-pages where we’ve listed the actions which can be set on the buttons.