JSON Schema Form

Allows users to add one or more custom fields to the configure and define a JSON schema and UI schema, to build a form. The schemas decide the behaviour of the fields and the form.

Basic

JSON Schema

The JSON schema defines the underlying data to be shown in the UI (objects, properties, and their types).

{
  "title": "User Information",
  "description": "Form Example",
  "type": "object",
  "required": [
    "name",
    "phone"
  ],
  "properties": {
    "name": {
      "type": "string",
      "title": "Name"
    },
    "phone": {
      "type": "string",
      "title": "Phone",
      "minLength": 11
    },
    "birthday": {
      "type": "string",
      "title": "Birthday"
    }
  }
}

UI Schema

The UI Schema defines how this data is rendered as a form, e.g. the order of controls, their visibility and the layout.

{
  "name": {
    "ui:autofocus": true,
    "ui:emptyValue": ""
  },
  "phone": {
    "ui:help": "at least 11 characters"
  },
  "birthday": {
    "ui:widget": "date"
  }
}

Pre-filled Form Data

The actual data or the values for the fields defined by the schema. These values must be provided using JSON format as well, mapped with their fields.

{
  "name": "David",
  "phone": "13488886666",
  "birthday": "1980-03-16"
}

Interaction

Submit - This is triggered when the user submits the form after filling out the details with valid values.

Hide

This sets whether the widget has to be displayed on the screen when the program is loaded. This shows/hides the widget both on desktop and mobile devices.

Reset After Successful Submit

All the input widgets on the form are cleared out after the form is submitted successfully, when this property is set ON.

Layout

Height

Auto

The height is auto-adjusted for the content

Fixed

The height of the widget is fixed and will not adjust to the content

Style

PropertyDescription

Background

Users can change the colour of the widget background using this property. It has all the RGB colour ranges to pick from. It is recommended to use a corresponding background colour that shows the font clearly.

Box Shadow

The is the colour of the shadow that is generated behind the widget box. The X and Y axis values can be altered such that the shadow can be set to fall anywhere behind the widget area. "x-offset" - a positive number specifies the shadow will be on the right of the box, and a negative number will put the shadow on the left of the box. "y-offset" - a negative one means the shadow will be above the box, and a positive number means the shadow will be below the box. "Blur" - if the number is set to 0 then the shadow will be sharp. It will more blurred as the number goes higher, and the shadow will extend further away. "Color" - sets the colour of the shadow. If the colour is not set, the box shadows are drawn in the foreground colour.

Border Color

Set the colour to the border lines. The border lines will be shown only if that is enabled.

Border Radius

This sets the radius of the widget's corners, enabling rounded corners on the widget. This value is defined in "px" terms.

Border Width

Set the thickness of the border of the widget using this value. It is defined using "px" terms.

Last updated