-
Notifications
You must be signed in to change notification settings - Fork 29
6.8. MultiChoiceCheckBox
This is a view with a list of checkboxes used especially when you want to pick more thatn one option. It is identified by type multi_choice_checkbox in the JSON.
All JSON attributes are represented as a String literals
| 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 |
Mostly matching the attributes on the XML but using snake case.
| View Attribute | Usage | Required |
|---|---|---|
| text | Label of the the multi choice checkboxes view | yes |
| label_text_size | Text size of the title of the widget | no |
| options_text_size | Text size of the labels for the options | no |
| 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 |
{
"name": "choose_language",
"type": "multi_choice_checkbox",
"properties": {
"text": "Pick the languages you are proficient in."
},
"options": [
{
"name": "eng",
"text": "English",
"meta_data": {
"openmrs_entity": "",
"openmrs_entity_id": "A123123123123",
"openmrs_entity_parent": ""
}
},
{
"name": "french",
"text": "French",
"meta_data": {
"openmrs_entity": "",
"openmrs_entity_id": "A123123123123",
"openmrs_entity_parent": ""
}
},
{
"name": "kisw",
"text": "Kiswahili",
"meta_data": {
"openmrs_entity": "",
"openmrs_entity_id": "A123123123123",
"openmrs_entity_parent": ""
}
},
{
"name": "need_help",
"text": "Help me choose",
"is_exclusive": true,
"meta_data": {
"openmrs_entity": "",
"openmrs_entity_id": "A918928912",
"openmrs_entity_parent": ""
}
},
{
"name": "none",
"text": "None of the above",
"is_exclusive": true,
"meta_data": {
"openmrs_entity": "",
"openmrs_entity_id": "A123123123123",
"openmrs_entity_parent": ""
}
}
],
"validation": [
{
"condition": " value != null && value['need_help'] == null",
"message": "You should be speaking at least one of the languages man!"
}
],
"required_status": "yes:Please specify your languages",
"subjects": "email_subscription:map, gender:text"
}
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.
This field stores value of a list of the map of selected options represented as (selected_item_name-> selected_item_text)
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
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.
Created by Elly Nerdstone with the help of some awesome contributors. License Apache 2.0