Skip to main content

Screens

To create a valid form, you need to understand the structure and elements of the Screen class. Below is a detailed documentation of each element of the Screen object.

Screen Object

A Screen object represents a screen in the form and contains various elements such as components, fields, layouts, and navigation details.

JSON Example

{
"components": [...],
"fields": [...],
"layout": {...},
"next_screens": [...],
"screen_name": "Example Screen",
"next_button": "Next",
"previous_button": "Previous",
"buttons": {...},
"ai": {...},
"progression": true
}

Elements of Screen

components

  • Type: List of Component
  • Mandatory: true
  • Description: A list of components that are part of the screen.
  • Documentation: Creating a Valid Component

Example:

"components": [
{
"type": "text",
"data": "Example Text",
"name": "example-text"
}
]

fields

  • Type: List of FieldRef
  • Mandatory: true
  • Description: A list of field references used in the screen.
  • Documentation: Creating a Valid FieldRef

Example:

"fields": [
{
"slug": "my-field-slug",
"metadata": {},
"default": "this is a deault value for a Text field",
}
]

layout

  • Type: Layout
  • Mandatory: true
  • Description: Defines the layout of the screen.
  • Documentation: Creating a Valid Layout

Example:

"layout": {
"type": "column",
"children": [
{
"type": "component",
"name": "example-component"
}
]
}

next_screens

  • Type: List of ScreenLink
  • Mandatory: true
  • Description: A list of links to the next screens based on conditions.
  • Documentation: Creating a Valid ScreenLink

Example:

"next_screens": [
{
"condition": "true",
"screen_name": "Next Screen"
}
]

screen_name

  • Type: String
  • Description: The name of the screen.

Example:

"screen_name": "Example Screen"

next_button

  • Type: String
  • Description: The label for the next button.

Example:

"next_button": "Next"

previous_button

  • Type: String
  • Description: The label for the previous button.

Example:

"previous_button": "Previous"

buttons

  • Type: ButtonLayout
  • Description: Defines the layout of buttons on the screen.

Example:

"buttons": {
"type": "row",
"children": [
{
"type": "button",
"name": "submit-button"
}
]
}

progression

  • Type: Boolean
  • Description: Indicates if the screen progression is enabled.

Example:

"progression": true

A ScreenLink object represents a link to an other screen based on his name and a condition.

JSON Example

{
"condition": "true",
"screen_name": "Next Screen"
}

condition

  • Type: String
  • Mandatory: true
  • Description: The Lua condition to navigate to the referenced screen.

Example:

"condition": "get_screen_condition()"

screen_name

  • Type: String
  • Description: The name of the referenced screen.

Example:

"screen_name": "my next screen name"

calculated_screen_name

  • Type: String
  • Description: A Lua function returning the name of the referenced screen.

Example:

"calculated_screen_name": "get_next_screen()"

ai

  • Type: Ai
  • Description: Define form ai behavior. Must be defined only in the first screen.

Example:

"ai": {...}