-
Notifications
You must be signed in to change notification settings - Fork 30
EditText Field
This is a Material design text input field that is identified by type edit_text
in the JSON.
Field Attribute | Usage | Required |
---|---|---|
key | Unique of the field | yes |
type | Type of the field | yes |
hint | The hint/text displayed to the user | no |
edit_type | The input type required by the field name - Allows the user to enter alphanumerics, number - Only allows numerics |
yes |
value | Holds the user entry. Its a string literal. Only needed incase the field has a predifined entry otherwise its always auto generated/automatically added through code |
no |
read_only | Holds the read only status of a specific field. true - means the user cannot entry/type anything on the field. They can only view what is presented |
no |
v_regex | Holds a validation regex. This validates the data entered in the field | no |
v_numeric | no | |
v_min | Defines the minimum value that can be used as an input. Mostly used with edit_texts of edit_type = "number"
|
no |
v_max | Defines the maximum value that can be used as an input. Mostly used with edit_texts of edit_type = "number"
|
no |
v_required | Status to indicate whether this field is required or not | no |
relevance | Holds the rules to show/hide the specific field. This can use rules engine/ the line relevance (show in the example below) | no |
calculations | Holds the link to the rules files that has a calculation affects the field in question | no |
openmrs_entity_parent | Holds the concept id of the parent concept in OpenMRS | no |
openmrs_entity | Holds the entity type on OpenMRS e.g Person , Address , Concept
|
no |
openmrs_entity_id | Holds the concept id from OpenMRS | no |
{
"key": "user_last_name",
"openmrs_entity_parent": "",
"openmrs_entity": "",
"openmrs_entity_id": "",
"type": "edit_text",
"hint": "User Last name",
"edit_type": "name",
"value":"Doe",
"read_only": true,
"v_required": {
"value": "true",
"err": "Please enter the last name"
},
"v_regex": {
"value": "[A-Za-z\\s\\.\\-]*",
"err": "Please enter a valid name"
},
"v_numeric": {
"value": "true",
"err": ""
},
"v_min": {
"value": "30",
"err": "Weight must be equal or greater than 30"
},
"v_max": {
"value": "180",
"err": "Weight must be equal or less than 180"
},
"relevance": {
"step1:user_first_name": {
"type": "string",
"ex": "equalTo(., \"test\")"
}
},
"calculation": {
"rules-engine": {
"ex-rules": {
"rules-file": "sample-calculation-rules.yml"
}
}
}
}
v_regex
, v_min
, v_max
, v_numeric
are used to validate the field. The value
attributte on the mentioned JSON objects holds the validation rules required. The err
attributte holds the error message to be display incase the condition defined is not fulfilled/evaluates to false.
To make field required add v_required
attribute with value true
. The text on the err
attributte will be displayed to the user incase the field is not filled.
"calculation": {
"rules-engine": {
"ex-rules": {
"rules-file": "sample-calculation-rules.yml"
}
}
}
The block above shows the rules engine relevance block.
"relevance": {
"rules-engine": {
"ex-rules": {
"rules-file": "sample-relevance-rules.yml"
}
}
}
The block above shows the rules engine relevance block.
Forked from Android Native JSON Form Library. Adapted in love by the OpenSRP Community . Apache License, Version 2.0
Introduction
Core Features
Form
Views