button

A button can be linked to various actions.

Configuration

For general configuration options, see General component configuration.

Specific configuration

type ("button")

Type of component.

action (enum<"print" | "reset" | "setProperty" | "submit" | "validate">)

Identifies the action that is triggered by this button. Other actions cannot be used directly, but are available via onClick, for example.

target (Binding)

Required if the action is used setProperty is used.

value (any | Binding)

Required if the action is used setProperty is used.

General configuration

In addition to the configurations valid for all, the following configurations can optionally be set: disabled, //errorTarget, icon, label. //onChange, //readOnly, //required.

Actions

reset

Resets the page. See Reset.

setProperty

Overwrites a button with a specific value depending on another value. For this, target and value must also be defined. With target, a variable is bound in the state which is changed according to the value in value. Practically, this function can be used to jump between different pages of a form, as shown here.

submit

Triggers the submit function, which transmits the current form to the backend system.

validate

Triggers the validation. This checks the data entered in the form.

Example

button.json
{
  "$schema": "https://forms.virtimo.net/5.1.0/schema.json",
  "metaData": {
    "id": 0,
    "version": 0
  },
  "configuration": {
  },
  "components": [
    {
      "type": "container",
      "label": "Button Component Example",
      "components": [
        {
          "type": "button",
          "label": "My Button"
        },
        {
          "type": "button",
          "action": "submit",
          "label": "Submit Button"
        },
        {
          "type": "button",
          "action": "reset",
          "label": "Reset Button"
        },
        {
          "type": "button",
          "action": "validate",
          "label": "Validate Button"
        },
        {
          "type": "button",
          "action": "print",
          "label": "Print Button"
        },
        {
          "type": "button",
          "label": "Add ' a'",
          "action": "setProperty",
          "target": "${/data/text}",
          "value": "${/data/text} a"
        },
        {
          "type": "textfield",
          "value": "${/data/text}",
          "required": true
        }
      ]
    }
  ],
  "state": {
    "data": {
      "text": ""
    }
  }
}
Embedded preview

Keywords: