Logic
Adding Logic to a component allows for changing the component definition in reaction to data entered in a form. For two examples, see this page.
Properties
Name | Description | Datatype | Default |
---|---|---|---|
name | Name of the field logic. | String | 'My logic' |
trigger | When to trigger actions. Example:
| Struct/dict | |
actions | The action(s) to trigger. | cell/list |
Trigger property
The trigger's 'type' field may have the values 'simple', 'javascript' or 'event'.
simple
When the trigger type
is 'simple', the trigger struct/dict must contain a field 'simple'. It must contain a struct/dict with fields:
- 'show': must contain a boolean,
- 'when': must contain the full key of another component and
- 'eq': must contain a value that is compared against the value of the component specified in 'when'
The component that contains the Logic object is shown
true/false when
the other component's value equals
the specified value.
javascript
When the trigger type
is 'javascript', the trigger struct/dict must contain a field 'javascript'. It must contain JavaScript code that assigns a boolean to a variable 'result'. This is described in more detail in section Custom JavaScript.
event
When the trigger type
is 'event', the trigger struct/dict must contain a field 'event'. It must contain the name of an event that is triggered in the form.
Actions property
The actions
property must contain a cell array / list containing one or more action structs/dicts.
The action's 'type' field may have the values 'property', 'value' or 'customAction'.
property
When the action type
is 'property', the action struct/dict must contain a field 'property'. It must contain a struct/dict with fields:
- 'value': the property to change
- 'type': the data type of the property
The action struct must also contain a field 'state' containing the value the specified property must get when the trigger of the Logic object is triggered.
value
When the action type
is 'value', the action struct/dict must contain a field 'value'. It must contain JavaScript code that assigns a value to a variable 'value'. This is described in more detail in section Custom JavaScript.
customAction
When the action type
is 'customAction', the action struct/dict must contain a field 'customAction'. It must contain JavaScript code that assigns a value to a variable 'value'. This is described in more detail in section Custom JavaScript.