Form Widget

General Setting

User can change following things in Form widget:

  • Widget Name - Name for widget which will be used data referenceFor Example, if widget name is 'Form', then data of widget is referenced as Form.formData.

  • Show Title - User can show/hide widget title

  • Title Color

  • Background Color

Widget Setting

In Widget Setting option, user can change following parameters:

  • Button Text

  • Button Text Color

  • Button Background Color

  • Form Schema

    Here, user can define schema for form with required fields, properties etc. Please refer below example.

// Form Schema

{
  "title": "A registration form",
  "description": "A simple form example.",
  "type": "object",
  "required": [
    "firstName",
    "lastName"
  ],
  "properties": {
    "firstName": {
      "type": "string",
      "title": "First name",
      "default": "Chuck"
    },
    "lastName": {
      "type": "string",
      "title": "Last name"
    },
    "telephone": {
      "type": "string",
      "title": "Telephone",
      "minLength": 10
    }
  }
}
  • UI Schema

    Here, user can customize each field of form. Different properties like autoFocus, autoComplete etc are available.

// UI Schema

{
  "firstName": {
    "ui:autofocus": true,
    "ui:emptyValue": "",
    "ui:autocomplete": "family-name"
  },
  "lastName": {
    "ui:emptyValue": "",
    "ui:autocomplete": "given-name"
  },
  "age": {
    "ui:widget": "updown",
    "ui:title": "Age of person",
    "ui:description": "(earthian year)"
  },
  "bio": {
    "ui:widget": "textarea"
  },
  "password": {
    "ui:widget": "password",
    "ui:help": "Hint: Make it strong!"
  },
  "date": {
    "ui:widget": "alt-datetime"
  },
  "telephone": {
    "ui:options": {
      "inputType": "tel"
    }
  }
}

If user define Form Schema and UI schema as above given example, the Form will be shown as below image.

Notes:

Source

Button widget does not support Source settings.

Event Handling

Form onSubmit event is provided. User can choose MQTT or Action mode for onSubmit event.

Using MQTT

User needs to provide following parameters:

  • event - Select onSubmit event from dropdown

  • mode - Select mode as MQTT

  • topic - Enter topic name directly. No need to provide accountID.

  • Data parameters - Add new data parameter item. Each data parameter item represent a key-value pair. So select required parameter and give key name to it.

As shown in below images, for onSubmit event, MQTT mode is selected. It means when user clicks on the submit button, it will publish configured data parameters on given MQTT topic.

So, as per the configuration shown in above images, when user clicks the button, JSON object with formKey-UserRole as key-value pair gets published on data topic. Please refer below image for final output.

Using Action

User needs to provide following parameters:

  • event - Select onSubmit event from dropdown

  • mode - Select mode as action

  • Action ID - Select required Action ID from dropdown

As shown in below images, for onClick event, action mode is selected. It means when user clicks on the button, it will trigger given Action with configured action parameters.

So, as per the example given in above images, when user clicks a button, updateFirebaseCloud action will trigger with JSON object of formDetails as key and JSON Object of Form as Value.

Last updated