Events
Events live in form.events.code and are evaluated at runtime. Use ON to register handlers
and SETVALUE/ALERT to interact with the form.
Creating an engine runs events.code once to register handlers. It does not dispatch an event.
An event runs only when your application calls engine.trigger(...) or a binding dispatches it for a user
interaction or application lifecycle transition.
Quick example
Code
Event dispatch in official bindings
By default, FormRenderer in form0-react and form0-react-native dispatches these events:
| Event | When it runs |
|---|---|
load-record | Each time a record opens, for editing or read-only |
new-record | A new record starts editing |
edit-record | An existing record starts editing |
change | A user edits a field, or adds, edits, or removes a repeatable section row |
focus, blur | A text or numeric input gains or loses focus |
validate-record | A user submits the form or saves a draft |
save-record | After validation, once for each save attempt |
cancel-record | A user confirms cancelling a record |
unload-record | A record closes |
change-status | A user changes the status field, if it is enabled |
Rows have their own events: load-repeatable, new-repeatable, edit-repeatable,
validate-repeatable, save-repeatable, cancel-repeatable, unload-repeatable. A row never runs
the main record's events.
Choice fields report changes through change, not focus or blur. click is available, but no
built-in control emits it, so dispatch it yourself. Defaults, calculations, and SETVALUE do not
dispatch change.
Use engineOptions.events to change this. lifecycle: false keeps only load-record,
edit-record, and change for main-record fields. fieldInteractions: [] turns off focus and
blur.
If you use form0-core directly, nothing is dispatched for you. Call
engine.trigger(eventType, fieldKey, metadata) at the right point in your application. Registering
a handler with ON does not make its event run.
Event builtins
Events
For registration, execution order, handler scope, and operation handling, see Events and operations.
Event handlers can also use the shared expression builtins listed in
Calculations & expressions. Calculation-only
builtins such as SETRESULT are not available in event handlers.