Back

Drupal Forms User Guide

Common elements part 1 (HTML, text fields, addresses and emails)

HTML sections

These allow you to add text, images and links to a form. If you are adding content specific to a question, try to use description or help text, as there is often quite a bit of padding around a HTML block, so it may not be obvious which element you are referring to. These are most useful for adding titles and subtitles to sections.

There are 2 options for HTML boxes, basic and advanced. For most cases the basic one is fine. The advanced one only adds support for media (video etc.), which are rarely used in forms.

Text fields

Text field boxes should be used for shorter text entries, usually a few words or a single sentence.

Remember the following:

  • avoid using placeholder text
  • make sure there isn't a more suitable input for the information you are trying to capture - for example, numbers, names, emails
  • you can set the maximum number of characters or words in the required section
  • they will always only ever be a single line in height and are not resizable

Text area

Use these for longer free text answers.

Be mindful that if you want to know specific information, you might be better off asking closed questions, rather than open ones. For example, ‘Do you have any debts?’ (a Yes or No radio button), instead of ‘Tell us about any debts you have’.

Remember that: 

  • English may not be the user's first language and they may be put off if they have to give too much detail
  • you can set the maximum number of characters or words in the required section

Name fields

When collecting the user's name, there are two options you can use:

  • a single text field element to capture the full name
  • a name element which can gather the first name and last name as two separate fields
What is your name

If you can, just ask for full name as a text field, as not all names match the first and last name pattern. See guidance on name patterns from GOV.UK.

When using the name element, bear the following in mind:

  • the default element also includes, title, middle name, suffix and degree - these should be switched off
  • the default labels for the first name and last name are 'First' and 'Last' - change these to 'First name' and 'Last name'
  • by default the question text (in this case, What is your name) is hidden, which isn't usually an issue, but if you need it to display you have to switch it to 'Before' in the Form display section

Capturing someones Title (Mr, Mrs etc) is not recommended. Find out if the stakeholder has a good reason to add it. See guidance on titles from GOV.UK.

Address fields

Where possible, use the address composite element that includes a postcode lookup. If a postcode does not exist, the user can add the address manually.

Address

    Leave default selections for viewing elements. They are all needed.  

    Do not set any fields to required or mandatory. Because there are two sets of address elements (auto and manual), we can’t set one postcode as required, as the other one might end up being used, and for the same reason, we can’t set both postcodes as one will always be hidden.

    Email fields

    Use the Email confirm element to reduce risk of inaccurate data.