Advanced guide: Building Drupal webforms

Looking for basic information on how to create a webform? Read this guide first.

This guide walks through the options available for building a webform in the Drupal CMS. Not all of the settings visible in the CMS back-end are configured to work/display on the front-end.

This form is attempting to document what will work, but is a work-in-progress that will continue to be updated as the Drupal webforms functionality improves.

On this page:

Form elements

Not all of the elements, options and settings visible in the CMS back-end are configured to work or display correctly on the front-end.

See our sample webform that shows all available elements and their most typical customisations and variations.

Element name

Supported?

Use case

Element name

Supported?

Use case

Checkbox

YES

  • A single checkbox with text that appears to the right of it.

  • Mostly used to ask the user to indicate their agreement, consent or confirmation of something, such as terms and conditions.

  • If adding description text to this element, it will display above the checkbox and title/label on the front-end – this isn’t recommended.

Hidden

YES

TBC

Textarea

YES

  • Use this when you want or expect users to provide a longer answer, e.g. “Describe your complaint”.

  • The field becomes scroll-able as lots of text is added to it.

  • appears as several lines with bottom-right corner expander; allows a lot of text including line breaks when pasted or typed 

Text field

YES

  • Use this when you want or expect users to only provide a short answer, e.g. “Full name”.

  • There is a default maximum character limit of 255 characters that will be accepted. You can customise this to be a number less than 255.

Email

YES

  • Use for collecting an email address, as this field will provide automatic valildation.

Height (feet/inches)

NO

 

Number

YES

  • Use this when you want the user to only provide numbers, as this field applies automatic validation and will give the user an error message if they enter letters or special characters.

  • Can set a minimum or maximum range, e.g. only allow for a number between 1 and 10 to be accepted. This is different to setting a maximum length of numbers – e.g. only allow for 10 digits – which is why this field isn’t ideal for collecting phone numbers.

Privacy statement

YES

  • Consists of a HTML field (with SDP’s default collection notice template) and a single checkbox (asking for the user to confirm they’ve read and understood).

  • Added to all new webforms by default. Text is editable.

  • Can be removed if required/desired.

    • All forms collecting personal information should include a collection notice though.

  • Can’t apply conditional logic to this element.

Telephone

 YES

TBC

URL

 YES

Will only accept a URL that includes “https://www.” at the start.

If using this element, please include this information in the description field, as there isn’t a specific error message that tells the user this is the problem. It may be a safer option to use the Text field element instead, to account for users who provide different variations of URLs.

Advanced address

 YES

Can’t apply conditional logic to this element.

Advanced HTML/Text

YES

Use this when you want to include text within your form that isn’t a question / doesn’t require an answer. For example, when creating a decision tree and wanting to supply an answer or more context at the end of a pathway.

This element includes more WYSIWYG toolbar options than the Basic HTML element. Includes the basics of heading sizes, bold and italics, hyperlinks and list formatting as well as extra options such as adding buttons and call-out formatting.

Basic HTML

YES

Same use case as the Advanced HTML/Text element, but with less WYSIWYG toolbar options.

Includes the basics of heading sizes, bold and italics, hyperlinks and list formatting.

Horizontal rule

YES

Applies a horizontal line within your form. Use sparingly, if at all.

Label

 YES

TBC

Date

 YES

TBC

Checkboxes

YES with some limitations

Only the “Custom options” option is supported; the predefined options are not.

Radios

YES with some limitations

Only the “Custom options” option is supported; the predefined options are not.

For example, to set up a question with Yes and No options as the response, select “Custom options” and then add “Yes” and “No” as the 2 values.

Select

YES with some limitations

Only the “Custom options” option is supported; the predefined options are not.

Only single select is supported; multi-select is not.

Submit button(s)

YES with some limitations

Only the Submit version is supported (not save, etc.)

The 1.45 release allows for conditional logic to be applied to the submit button.

Term select

YES

Dropdown list that allows multiple selects, must be linked to taxonomy 

General tab

Element settings, options and description text

Field

Supported?

Use case or example

Field

Supported?

Use case or example

Title

YES

  • The “label” that will display above the element on the front-end

  • For example: if you have a text field for the user’s name you would write “Full name” in this section and that will appear above the text field.

Allowed number of values

NO

 

Options

YES

  • Used for the Checkboxes, Radios and Select elements.

  • Only the “custom options” choice works. This requires you to manually write in each option you want to have displayed.

    • What you write in the Option Value column will automatically be added to the Option Text column. You can overwrite this so the columns are different, but this isn’t recommended.

  • Choosing one of the predefined options will work fine in the back-end, but not the front-end.

Options display

Options description display

NO

NO

 

Empty option

YES

  • This is the text that appears within the Select element, to signal that the field hasn’t been answered/filled yet.

  • Default text is “Select”.

Empty value

NO

 

Sort options

NO

 

Randomize options

NO

 

Select2

NO

 

Choices

NO

 

Description

YES

  • This text appears under the element’s title/label.

  • It should be used to provide more context or instructions for the user. It is possible to format this text, e.g. add lists or hyperlinks.

Help text

NO

 

Help title

NO

 

More text

NO

 

More title

NO

 

 Form display

Field

Supported?

Use case or example

Field

Supported?

Use case or example

Title display

NO

 

Description display

NO

 

Help display

NO

 

Field prefix and Field suffix

NO

 

Minlength and Maxlength

YES

  • This will add a minimum and maximum “length” (e.g. character limit for text fields) to the element.

  • Similar functionality to the Counter option, but that option will allow you to choose words instead of characters.

Size

NO

 

Placeholder

YES

  • This is text that appears within the element (e.g. a text field), often used as an example of what to put in the field:

  • The Vic Gov digital guide and Aus Style Manual recommend not using placeholder text, as it will disappear when a person clicks in the field and is usually of very low contrast. It may also confuse some users about whether they’ve completed a field or not.

  • Writing clear labels and descriptions is a better option than using placeholders.

Autocomplete + autofill

NO

 

Input masks

NO

 

Input hiding

NO

 

Disabled

NO

 

Readonly

NO

 

Prepopulate

NO

 

Form validation

Field

Secondary fields

Supported?

Use case or example

Field

Secondary fields

Supported?

Use case or example

Required

YES

The user must enter a value for this element or they can’t submit the form

 

Required message

YES

  • This appears if you select the option to make this element required

  • If left blank, default message used is “This field is required!”

  • You can add a custom message to display instead.

Unique

 

NO

 

Pattern

 

NO

 

Counter

YES

  • Limit the entered value for the element to a minimum and/or maximum number

  • Choose between characters or words

  • Default option is set to “none”

  • Not applicable to form elements that don’t allow for text and numbers to be added by the user, e.g. radio buttons, checkboxes, select option.

 

Counter minimum and maximum

YES

  • Set the minimum value in numerals

  • Set the maximum value in numerals

 

Counter maximum message

NO

  • This isn’t currently configured for custom messages.

  • The default message used is “The length of text is too small/big! Current: X, Minimum/Maximum: X”.

Conditions tab (conditional logic)

State

Supported?

Use case or example

State

Supported?

Use case or example

Visible

YES

 

Hidden

YES

 

Visible (Slide)

NO

 

Hidden (Slide)

NO

 

Enabled

YES

 

Disabled

YES

 

Read/write

NO

 

Read-only

NO

 

Required

YES

 

Optional

NO

 

Operators

Supported?

Use case or example

Operators

Supported?

Use case or example

All

YES

 

Any

YES

 

One

YES

 

Choose the element (i.e. the question/field on the form) that will affect whether this current element gets triggered.

For example:

  • You’re editing the Conditions of an email element.

  • You select the state to be Visible > if One of the following is met

  • In the next dropdown menu choose the Radios element you have labelled “Do you want to be emailed?

  • Assign the trigger to be Value is

  • Select the value Yes.

Trigger/value

Supported?

Use case or example

Trigger/value

Supported?

Use case or example

Empty

YES

 

Filled

YES

 

Checked

YES

Use when the question the logic applies to is using the Checkbox or Checkboxes element.

Unchecked

YES

Use when the question the logic applies to is using the Checkbox or Checkboxes element.

Value is

YES

You will also need to select the specific value that should trigger this element.

Value is not

YES

 

Pattern

YES

 

Not pattern

YES

 

Less than

YES

 

Less than/Equal to

TBC

 TBC

Greater than

YES

 

Greater than/Equal to

TBC

 TBC

Between

TBC

 TBC

Not between

TBC

 TBC

Currently only a single state of conditional logic is supported. For example: You can set a field up to become visible based on logic, but not also to be hidden based on different logic.

It’s also not possible to create multiple versions of the same ‘state’. For example: you can’t set up conditional logic make a field “visible” if it meets A + B or C. The only option is to set up 1 “visible” state that has the requirements of meeting either “ANY” (A or B or C) or “ALL” (A and B and C) options provided.


Advanced tab


Access tab


Customising the settings for the entire form

Information about what’s configured or not configured in the Settings tab is available in our Advanced guide: Drupal webform settings.


Related articles