Perspective - Form Scripting
This page details the component-specific events and functions available for Perspective's Form component. Right-click on the component or select Components from the Designer menubar to access the Configure Events and Configure Scripts popups.
Component Events​
The Perspective Event Types Reference page describes all the possible component event types for Perspective components.
onChange​
This event triggers whenever a form's input value changes.
Properties​
| Property | Type | Description |
|---|---|---|
| event.inputKey | String | The unique key identifying the input that triggered the change. |
| event.newValue | Object | The new value of the input after the change. |
| event.oldValue | Object | The previous value of the input before the change occurred. |
| event.index | Integer | The index of the input if multiple inputs share the same key, such as in a repeater or table. Optional. |
onSuccess​
This event triggers when a form submission completes successfully.
Properties​
| Property | Type | Description |
|---|---|---|
| event | Object | The success response object returned after submission. |
See Form Submission for handling form data on submission.
onError​
This event triggers when a form submission fails.
Properties​
| Property | Type | Description |
|---|---|---|
| event | Object | The error response object returned from the submission. |
See Form Submission for handling errors.
onCancelActionPerformed​
If configured, this component event fires when the Form's cancel action is clicked.
Properties​
| Property | Type | Description |
|---|---|---|
| event | Object | A JSON object containing all form input data to be cancelled. |
onSubmitActionPerformed​
If configured, this component event fires when the Form's submit action is clicked.
Properties​
| Property | Type | Description |
|---|---|---|
| event | Object | A JSON object containing all form input data to be submitted. |
Component Functions​
.setCustomValidity(message, inputKey, index)​
Description​
Sets a custom validation message for a specific input field in the form.
Parameters​
| Parameter | Type | Description |
|---|---|---|
| message | String | The custom validation message to display for this input. |
| inputKey | String | The unique key identifying the input field. |
| index | Integer | The index of the input if multiple inputs share the same key. Optional. |
Return​
None
Example​
To set a custom validation message for an email input field:
self.getSibling("Form").setCustomValidity("Please provide a valid email address.", "email")
This message will persist until the field is corrected or the form is reset.
.reset()​
Description​
Resets all form inputs to their default values.
Parameters​
None
Return​
None
Example​
To reset the form inputs to their default state:
self.getSibling("Form").reset()
.submit(preventInvalid)​
Description​
Submits the form, triggering onSuccess if successful or onError if submission fails.
Parameters​
| Parameter | Type | Description |
|---|---|---|
| preventInvalid | Boolean | When true, prevents the form from submitting if it is invalid. Optional. |
Return​
None
Example​
To submit the form with validation check enabled:
self.getSibling("Form").submit(preventInvalid=True)
Extension Functions​
This component does not have any extension functions associated with it.