Add form fields

Form fields can be added to any Riddle type (Poll, Quiz, Form, Predictor). They allow you to collect user input.

You can choose between two options:

  1. Add a form with form fields to this Riddle
  2. Embed an already published Riddle form from your (personal) project

Embedding another form allows you to reuse a form you have already created (= central data collection) but also allows you to build more complex forms than with the builder API.

Add form to Riddle

Like any other block you might add, such as SingleChoice, you can add form fields to the Riddle build by adding a FormBuilder block item to the blocks array.

Properties

The form fields / builder block consists of:

PropertyRequiredTypeDescriptionDefault
titlestringThe title of the form builder
descriptionstringThe description of the form builder
typestringSet to FormBuilder
fieldsobjectAn object where the key is the field label and the value is the field type OR an advanced configuration ovject. The field type must be one of the available form fields
isRequiredbooleanWhether the form is required; if set to false the form can be skippedfalse

Example

The FormBuilder block isolated:

{
    "title": "My form builder",
    "type": "FormBuilder",
    "fields": {
        "Your email": "Email",
        "Your name": "Name"
    }
}

Used in a poll build:

{
    "type": "Poll",
    "build": {
        "title": "My new poll",
        "blocks": [
            {
                "title": "The best noodles?",
                "type": "SingleChoice",
                "items": [
                    "Spaghetti",
                    "Fusilli"
                ]
            },
            {
                "title": "My form builder",
                "type": "FormBuilder",
                "fields": {
                    "Your email": "Email",
                    "Your name": "Name"
                }
            }
        ],
        "result": {
            "title": "Thank you!",
            "description": "We are happy to have you here"
        }
    }
}

Note: You can add as many form builders as you like as long as you stay within the 20 blocks limit.

Available form fields

  • Name
  • Email
  • Phone
  • URL
  • Number
  • Country
  • ShortText
  • LongText
  • DatePicker
  • TimePicker
  • Checkbox
  • Radio buttons (see documentation below)
  • Dropdown (see documentation below)

Please note that the field type you send to the API is case-sensitive.

Add complex form fields

All form fields can be further customized by converting the simple input string, e.g. Email, to an object. This allows you to further customize the field and how it behaves.

Here is an example how an Email field can be customized inside a FormBuilder block:

{
    "title": "My form builder",
    "type": "FormBuilder",
    "fields": {
        "Your email": {
            "type": "Email",
            "placeholder": "Enter your email address",
            "isRequired": true,
            "requiredMessage": "We will never share your email with anyone else."
        }
    }
}

Form field properties

Each form field supports different options. This table illustrates what options are available for which type:

PropertyDescriptionAvailable for...
descriptionDescription of the fieldall types
placeholderPlaceholder textName, Email, Phone, URL, Number
prefilledTextPrefilled textName, Email, Phone, URL, Number
isRequiredWhether the field is requiredall types
requiredMessageMessage shown when the field is required but not filledall types
isHiddenWhether the field is hidden; useful in combination with the Riddle data layerName, Email, Phone, URL, Number
regexRegex to validate the fieldName, Email, Phone, URL, Number
regexValidationMessageMessage shown when the regex validation failsName, Email, Phone, URL, Number
checkboxTextText shown next to the checkboxCheckbox

Adding radio buttons and dropdowns

The RadioButtons and Dropdown field types can be used to create a list of options. You can add as many options as you like in the items array.

Example FormBuilder object:

{
    "title": "My form builder",
    "type": "FormBuilder",
    "fields": {
        "Your favorite color": {
            "type": "RadioButtons",
            "items": [
                "Red",
                "Green",
                "Blue"
            ]
        },
        "Your favorite animal": {
            "type": "Dropdown",
            "items": [
                "Dog",
                "Cat",
                "Fish"
            ]
        }
    }
}

Embed an already published form

You can embed a form from your (personal) project by adding a block of the FormSelect type to the blocks array.

Properties

The form select block consists of:

PropertyRequiredTypeDescription
formstringThe UUID of the form you want to embed

Example

The FormSelect block isolated:

{
    "type": "FormSelect",
    "form": "hQ3SYWur"
}

Used in a poll build:

{
    "type": "Poll",
    "build": {
        "title": "My new poll",
        "blocks": [
            {
                "title": "The best noodles?",
                "type": "SingleChoice",
                "items": [
                    "Spaghetti",
                    "Fusilli"
                ]
            },
            {
                "type": "FormSelect",
                "form": "hQ3SYWur"
            }
        ],
        "result": {
            "title": "Thank you!",
            "description": "We are happy to have you here"
        }
    }
}