Skip to content

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.

PropertyTypeRequiredDescription
questionstringYesThe label or question text shown to the user
display_typestringYesHow the input renders (see Display Types)
data_typestringYesThe data type of the value (see Data Types)
keystringYesUnique identifier for the field, used in conditionals. Must be unique across all fields
requiredbooleanYesWhether the field must be filled before submission
sectionstringNoThe id of the section this field appears in
hintstringNoHelper text displayed beneath the field
placeholderstringNoPlaceholder text shown inside the input
entry_titlebooleanNoIf true, this field's value is used as the display title for the collected entry
regexstringNoA regular expression pattern the value must match. Backslashes must be double-escaped (e.g. \\d)
column_namestringNoColumn name to use for this field's value in exported data, instead of key
auto_populatebooleanNoIf 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:

json
{
  "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_case that describes the data (e.g. owner_phone, not q12).
  • 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_name instead.

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, a checkbox stores an array and a range stores a number. 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 as example@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: if true, 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:

json
"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: when true, 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 uses key. Set column_name when 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_field filled from the logged-in user.
  • The survey date: a date field stamped with the date of submission.
json
{
  "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 TypeUsed withDescription
textText inputs, drop_down, radioA single string value
numbernumber, rangeA numeric value
arraycheckboxA list of selected values
datedateA calendar date
fileimageA captured file, such as a photo

Choice-Based Properties ​

Used with drop_down, radio, and checkbox fields.

PropertyTypeRequiredDescription
choicesarray | objectYesThe selectable option values. Use an object to group choices
sub_keystring | arrayWith grouped choicesKey(s) that store the answers below the top level. Use an array when groups are nested more than one level deep
default_valuearrayNoPre-selected value(s). Must always be an array, even for single-select fields
json
{
  "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.

json
{
  "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.

json
{
  "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:

KeyValue
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_key needs 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_key must 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.

PropertyTypeDescription
min_lengthnumberMinimum number of characters (text) or minimum value (range)
max_lengthnumberMaximum number of characters (text) or maximum value (range)
fromnumberThe starting value of a range input
tonumberThe ending value of a range input
stepnumberThe increment between values in a range input
json
{
  "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 TypeDescriptionProperties
text_fieldSingle-line text inputmin_length, max_length, regex
text_areaMulti-line text inputmin_length, max_length
drop_downSingle-select dropdown listchoices, default_value
radioSingle-select radio buttonschoices, default_value
checkboxMulti-select checkboxeschoices, default_value
numberNumeric input with number keyboarddefault_value
rangeNumeric sliderfrom, to, step
dateDate picker—
emailEmail address input with keyboard optimizationregex
phonePhone number input with numeric keyboardregex
imageImage capture input—