Text inputs allow users to enter text that’s no longer than a single line.
In addition to #govuk_text_field, the form builder supports
various other methods that take the same parameters and produce inputs for
particular data types:
Input types supported by the form builder
Method
Input type
Documentation
#govuk_number_field
number
MDNdocumentation for number inputs , WHATWGstandard document for number inputs
#govuk_phone_field
tel
MDNdocumentation for telephone inputs , WHATWGstandard document for telephone inputs
#govuk_email_field
email
MDNdocumentation for email inputs , WHATWGstandard document for email inputs
#govuk_url_field
url
MDNdocumentation for URL inputs , WHATWGstandard document for URL inputs
When used, these fields will look and act the same on desktop but mobile
browsers will present a different keyboard depending on the
type attribute.
All values passed into the form helper that aren’t among its named
parameters will be set as HTML attributes.
This feature is useful when requesting non-quantity values like
account numbers, payment card numbers and sort codes. There are
more details on the reasoning behind this decision in the accompanying blog post.
Prefixes and suffixes are useful when you use symbols and abbreviations
that are commonly known and understood. Symbols and abbreviations should
be explained in the label or hint.
By default, inputs will expand to fill their container. When no
width parameter is passed in no width class will be added.
Custom widths help users understand the length of the value they are
intended to enter. For example, a telephone number input needn’t be the
full width of the page when it might only be 11 digits long.
When asking for long codes, references or phone numbers we can make the
text in the field more readable by adding some extra spacing between
characters.