Form Fields
The fields array contains objects that represent individual questions in the survey. Each object must include a display_type that determines how the input renders on the device.
Common Properties
These properties apply to all field types.
| Property | Type | Required | Description |
|---|---|---|---|
question | string | Yes | The label or question text shown to the user |
display_type | string | Yes | How the input renders (see Display Types) |
data_type | string | Yes | The data type of the value (see Data Types) |
key | string | Yes | Unique identifier for the field, used in conditionals. Must be unique across all fields |
required | boolean | Yes | Whether the field must be filled before submission |
section | string | No | The id of the section this field appears in |
hint | string | No | Helper text displayed beneath the field |
placeholder | string | No | Placeholder text shown inside the input |
entry_title | boolean | No | If true, this field's value is used as the display title for the collected entry |
regex | string | No | A regular expression pattern the value must match. Backslashes must be double-escaped (e.g. \\d) |
column_name | string | No | Column name to use for this field's value in exported data, instead of key |
auto_populate | boolean | No | If true, the value is filled in automatically (e.g. the enumerator from the login, or the date on submission) |
A field that uses most of these properties looks like this:
{
"key": "owner_phone",
"section": "section_owner",
"question": "Owner's Phone Number",
"display_type": "text_field",
"data_type": "text",
"required": true,
"hint": "Include the country code if the number is not local",
"placeholder": "+234 801 234 5678",
"regex": "^\\+?[0-9]{7,15}$",
"column_name": "OWNER_PHONE",
"entry_title": false
}The sections below explain each property by what it does.
Identity: key
key is the field's permanent ID. The collected value is saved under this name, and conditionals use it to refer to the field.
- It must be unique across the whole survey, including every
sub_key. - Use lowercase
snake_casethat describes the data (e.g.owner_phone, notq12). - Avoid renaming a key once data has been collected. Old and new entries would store the same answer under different names. To change how the column is labelled in exports, set
column_nameinstead.
Rendering: question, display_type, data_type
These three properties are required on every field. They decide what the user sees and what kind of value is stored.
question: the label shown above the input. Write it the way you would ask the respondent.display_type: the control shown to the user, such as a text box, dropdown, radio buttons or camera. See Display Types.data_type: the type of value stored. It has to match the display type; for example, acheckboxstores anarrayand arangestores anumber. See Data Types.
Guidance: hint and placeholder
Both help the user answer correctly, but they appear in different places.
hint: a longer explanation available from the info icon next to the question. Use it for instructions, such as "Measure from the front gate" or "Include the country code".placeholder: faint example text inside an empty input that disappears when the user starts typing. Use it to show the expected format, such asexample@domain.com. It only applies to inputs the user types into.
A placeholder is not a value. If the user leaves the field empty, nothing is saved.
Validation: required and regex
required: iftrue, the form cannot be submitted until this field has a value.regex: a pattern the answer must fully match before the form can be submitted. Use it for structured values such as phone numbers, emails or ID codes.
Because the survey is JSON, every backslash in a pattern must be written twice. To match one digit (\d in a normal regex), write:
"regex": "^\\d+$"Anchor patterns with ^ and $ so they match the whole answer, not just part of it. For more checks, see Validation Rules.
Layout: section
section puts the field in a section of the form. Its value must match the id of one of the survey's sections. Fields appear in their section in the order they are listed in fields.
Records and exports: entry_title and column_name
entry_title: whentrue, this field's answer becomes the name of the entry in the app's list of collected records. Choose a field that makes each record easy to recognize, such as the owner's name or a property ID.column_name: the column header used for this field in exported data. By default the export useskey. Setcolumn_namewhen the export has to match an existing spreadsheet or database, e.g."TYPE_OF_ADDR".
Automation: auto_populate
When auto_populate is true, the app fills the value in and the user cannot edit it. It is typically used for:
- The enumerator: a
text_fieldfilled from the logged-in user. - The survey date: a
datefield stamped with the date of submission.
{
"key": "survey_date",
"question": "Date of Survey",
"display_type": "date",
"data_type": "date",
"required": true,
"hint": "Auto-stamped on submission",
"auto_populate": true
}Data Types
| Data Type | Used with | Description |
|---|---|---|
text | Text inputs, drop_down, radio | A single string value |
number | number, range | A numeric value |
array | checkbox | A list of selected values |
date | date | A calendar date |
file | image | A captured file, such as a photo |
Choice-Based Properties
Used with drop_down, radio, and checkbox fields.
| Property | Type | Required | Description |
|---|---|---|---|
choices | array | object | Yes | The selectable option values. Use an object to group choices |
sub_key | string | array | With grouped choices | Key(s) that store the answers below the top level. Use an array when groups are nested more than one level deep |
default_value | array | No | Pre-selected value(s). Must always be an array, even for single-select fields |
{
"question": "What is the type of house?",
"display_type": "radio",
"data_type": "text",
"key": "type_of_house",
"required": true,
"hint": "Select the type of house",
"default_value": ["BUNGALOW"],
"choices": ["BUNGALOW", "APARTMENT", "DETACHED", "SEMI-DETACHED"],
"entry_title": false
}Grouped Choices
For long, hierarchical lists, choices can be an object. Each property name is a group, and its value holds what is inside that group. The user picks a group first, then works down one level at a time until they reach an option.
The group is saved under the field's key. The option chosen within the group is saved under sub_key, which must be unique across the survey like any other key.
{
"key": "land_use",
"sub_key": "detail_land_use",
"question": "Primary Land Use",
"display_type": "drop_down",
"data_type": "text",
"required": true,
"choices": {
"Residential": [
"Low-density housing (detached / bungalow)",
"Traditional / mud house",
"Other"
],
"Commercial": [
"Retail shop / supermarket",
"Open market / stalls",
"Other"
]
}
}An entry with Commercial → Open market / stalls saves land_use as "Commercial" and detail_land_use as "Open market / stalls". Conditionals can test either key; see Grouped Choices in Conditionals.
More Than Two Levels
Groups can be nested as deep as you need. Instead of an array of options, give a group another object of groups. The last level is always an array of options.
With more than one level below the top, sub_key becomes an array with one key per level, in order from top to bottom. The top level is still saved under key.
{
"key": "zone",
"sub_key": ["state", "lga"],
"question": "Location",
"display_type": "drop_down",
"data_type": "text",
"required": true,
"choices": {
"North Central": {
"Niger": ["Minna", "Bida", "Suleja"],
"Kwara": ["Ilorin West", "Offa"]
},
"South West": {
"Lagos": ["Ikeja", "Surulere"],
"Oyo": ["Ibadan North", "Ogbomosho North"]
}
}
}The user picks a zone, then a state in that zone, then an LGA in that state. An entry with North Central → Niger → Bida saves:
| Key | Value |
|---|---|
zone | "North Central" |
state | "Niger" |
lga | "Bida" |
Rules for nested choices:
- Every branch must have the same number of levels. In the example above, every zone contains states and every state contains a list of LGAs.
sub_keyneeds exactly one entry per level below the top: a three-level list needs two keys. For two levels, a plain string and a one-item array (["detail_land_use"]) mean the same thing.- Every key in
sub_keymust be unique across the survey. - If the user changes an answer at one level, the answers below it are cleared, because they may no longer belong to the new choice.
Numeric & Text Properties
Used with text_field, text_area, and range fields.
| Property | Type | Description |
|---|---|---|
min_length | number | Minimum number of characters (text) or minimum value (range) |
max_length | number | Maximum number of characters (text) or maximum value (range) |
from | number | The starting value of a range input |
to | number | The ending value of a range input |
step | number | The increment between values in a range input |
{
"question": "What is your age?",
"display_type": "range",
"data_type": "number",
"key": "age",
"from": 1,
"to": 100,
"step": 1,
"required": true
}Display Types
The display_type property controls how the field renders in the mobile app.
| Display Type | Description | Properties |
|---|---|---|
text_field | Single-line text input | min_length, max_length, regex |
text_area | Multi-line text input | min_length, max_length |
drop_down | Single-select dropdown list | choices, default_value |
radio | Single-select radio buttons | choices, default_value |
checkbox | Multi-select checkboxes | choices, default_value |
number | Numeric input with number keyboard | default_value |
range | Numeric slider | from, to, step |
date | Date picker | — |
email | Email address input with keyboard optimization | regex |
phone | Phone number input with numeric keyboard | regex |
image | Image capture input | — |