-
Notifications
You must be signed in to change notification settings - Fork 28
6.6. SpinnerNFormView
This is drop down view used for selecting a single item among a list of options. It is identified by type spinner
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 spinner | yes |
searchable | Searchable text | no |
View Attribute | Usage | Required |
---|---|---|
text | Label of the the spinner | yes |
name | Unique name to identify the option | yes |
metadata / meta_data | Extra data to pass with the result | no |
{
"name": "country",
"type": "spinner",
"properties": {
"text": "Choose your country of Origin",
"searchable": "Search country"
},
"options": [
{
"name": "none",
"text": "Select country"
},
{
"name": "america",
"text": "United States Of America",
"meta_data": {
"country_code": "+1"
}
},
{
"name": "canada",
"text": "Canada",
"meta_data": {
"country_code": "+1"
}
},
{
"name": "uk",
"text": "United Kingdom",
"meta_data": {
"country_code": "+44"
}
},
{
"name": "australia",
"text": "Australia",
"meta_data": {
"country_code": "+61"
}
},
{
"name": "Kenya",
"text": "Kenya",
"meta_data": {
"country_code": "+254"
}
},
{
"name": "tanzania",
"text": "Tanzania",
"meta_data": {
"country_code": "+255"
}
},
{
"name": "china",
"text": "China",
"meta_data": {
"country_code": "+86"
}
},
{
"name": "sweden",
"text": "Sweden",
"meta_data": {
"country_code": "+1"
}
},
{
"name": "russia",
"text": "Russia",
"meta_data": {
"country_code": "+7"
}
},
{
"name": "japan",
"text": "Japan",
"meta_data": {
"country_code": "+81"
}
},
{
"name": "singapore",
"text": "Singapore",
"meta_data": {
"country_code": "+65"
}
}
],
"subjects": "email_subscription:map",
"required_status": "yes:Please specify your country"
}
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 map of the field_name -> (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