Skip to content

6.7. RadioGroupView

Elly Kitoto edited this page Apr 12, 2020 · 2 revisions

RadioGroup widget

This is radio group view used for selecting a single item among a list of options. It is identified by type radio_group in the JSON.

All JSON attributes are represented as a String literals

Field attributes

Field Attribute Usage Required
name Name of the field yes
type Type of the field yes
properties View attributes yes
options Options for the field yes
meta_data / metadata Extra data passed with the result of this field no
validation List of validations to perform on the field no
required_status Status to indicate whether this field is required or not no
subjects / binding_fields no
calculations / dependent_calculations / calculation_fields Calculations depending on this field no

Supported view attributes

Mostly matching the attributes on the XML but using snake case.

View Attribute Usage Required
text Label of the the radio group yes

Supported options attributes

View Attribute Usage Required
name Name of the option item yes
text Label of the option yes
metadata / meta_data Extra data to pass with the result no

Example JSON

{
  "name": "wiki_contribution",
  "type": "radio_group",
  "properties": {
    "text": "Have you ever contributed to or written a page in the Wiki?"
  },
  "options": [
    {
      "name": "yes",
      "text": "Yes"
    },
    {
      "name": "no",
      "text": "No"
    },
    {
      "name": "dont_know",
      "text": "Dont know"
    }
  ],
  "validation": [
    {
      "condition": "value != null && !value.containsKey('dont_know')",
      "message": "Don't know is not an option"
    }
  ],
  "required_status": "yes:Wiki contribution field is required.",
  "subjects": "email_subscription:map"
}

Field Validation

Validations are executed by Rules Engine in the order they are added on the list. To access the value of the field in the rules file, you can use a special neat form keyword called value alternatively you can use the field name. A field becomes invalid when any of the listed validation fails.

A validation has a condition and error message to be displayed on the view when the condition evaluates to false.

Field Value

This field stores value of a map of the field_name -> (selected_item_name-> selected_item_text)

Required Status

To make field required add required_status attribute with value Yes:error message or true:Your error message. Use no/false to negate the status

Rules

Add field:data_type to comma separated string list of the subjects / binding_fields attribute. as shown in the sample JSON above. For calculations add field names to the JSON array of dependent_calculations / calculation / calculation_fields attribute to watch for changes in the value of the view.