Questions
Questions are the basic building blocks of form definitions. To avoid having to duplicate questions, this separate library allows you to reuse the same question in multiple form definitions.
Answer types​
Various answer types are supported to ensure users can provide the necessary information in a structured way.
| AnswerType | Documentation |
|---|---|
TEXT | Textual input (single line) |
TEXT_AREA | Textual input (multiple lines) |
RICH_TEXT | Rich text input with formatting options (bold, italic, underline, numbers list and bullet list) |
NUMBER | Numeric input |
DATE | Calendar input |
PHONE | Phone input |
SINGLESELECT | Radio buttons: choices can be configured on the question |
MULTIPLESELECT | Checkboxes: choices can be configured on the question |
SINGLEDROPDOWN | Dropdown: choices can be configured on the question (use AUTOCOMPLETE when you have a lot of choice) |
AUTOCOMPLETE | Autocomplete dropdown (elements are fetched from a list) |
MULTI_AUTOCOMPLETE | Autocomplete dropdown where multiple elements can be selected (elements are fetched from a list) |
BOOLEAN_RADIO | Boolean answer (textual yes/no options with radio buttons) |
BOOLEAN_TOGGLE | Boolean answer (displayed as a toggle button) |
BOOLEAN_CHECKBOX | Boolean answer (displayed as a checkbox) |
COUNTRY | Country component with a fixed list of countries. |
MULTI_COUNTRY | Country component with a fixed list of countries that allows selecting multiple values. |
Depending on the selected answer type, additional configuration options may be available.
For example, for TEXT, an answer validation field can be configured to require that the answer is a valid email address.
For DATE, it's possible to configure that the date must be in the past or future.
Explore the question configuration in the admin UI to see the available options for each answer type.
Migration needed when switching between TEXT_AREA and RICH_TEXT!
Rich text editor values are saved with html formatting in the database. This means it is not straightforward to switch between a text-area and the rich text editor. The migration below can be used if you want to switch some_table.some_field from text-area to the editor. The migration encodes <, > and & and replaces new-lines by a proper html <br/>. Remember to migrate the _archive table if relevant.
The final not like '<p>%' is to avoid migrating rows that already contain html. This query can only be executed once! Double execution would lead to a double encoding of & to & to &amp;.
UPDATE some_table
SET some_field = REPLACE(REPLACE(REPLACE(REPLACE(some_field, '&', '&'),'<', '<'),'>', '>'), '\n', '<br/>')
WHERE
some_field IS NOT NULL
AND
(some_field LIKE '%&%' OR some_field LIKE '%<%' OR some_field LIKE '%>%' OR some_field LIKE '%\n%')
AND
some_field NOT LIKE '<p>%';
Required​
When a question is marked as required, the user must provide an answer before being able to submit the form. Depending on the answer type, the meaning of required may vary:
- For
TEXT,TEXT_AREA,RICH_TEXT,NUMBER,PHONE, andDATE, the user must provide a non-empty value. - For
SINGLESELECT,MULTIPLESELECT,SINGLEDROPDOWN,AUTOCOMPLETE,MULTI_AUTOCOMPLETE,COUNTRY, andMULTI_COUNTRY, the user must select at least one option. - For
BOOLEAN_RADIO, the user must select either Yes or No. - For
BOOLEAN_TOGGLEandBOOLEAN_CHECKBOX, the user must interact with the checkbox or toggle. This might change in the future.