Components
Error summary
Summarise form errors on the page and provide links to help users complete them.
Contents
HTML
<div class="tna-error-summary" data-module="tna-error-summary" data-disable-autofocus="true">
<div role="alert">
<h2 class="tna-error-summary__heading tna-heading-m">
There is a problem
</h2>
<ul class="tna-error-summary__list">
<li class="tna-error-summary__item">
<a href="#" class="tna-error-summary__link">Enter your full name</a>
</li>
<li class="tna-error-summary__item">
<a href="#" class="tna-error-summary__link">The date of the record cannot be in the future</a>
</li>
</ul>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| title | string |
The title text for the error summary. Default value: |
| headingLevel | number |
The heading level which represents an element from Default value: |
| items | array |
Required. The list of items to display in the error summary. |
| disableAutoFocus | boolean |
If |
| classes | string |
Classes to add to the error summary. |
| attributes | object |
HTML attributes (for example data attributes) to add to the error summary. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error message text. |
| href | string |
The ID of the form field related to this error message. (Requires a |
{% from "nationalarchives/components/error-summary/macro.njk" import tnaErrorSummary %}
{{ tnaErrorSummary({
title: "There is a problem",
headingLevel: 2,
items: [
{
text: "Enter your full name",
href: "#"
},
{
text: "The date of the record cannot be in the future",
href: "#"
}
],
disableAutoFocus: true
}) }}
Jinja
Important information
{% from "components/error-summary/macro.html" import tnaErrorSummary %}
{{ tnaErrorSummary({
"title": "There is a problem",
"headingLevel": 2,
"items": [
{
"text": "Enter your full name",
"href": "#"
},
{
"text": "The date of the record cannot be in the future",
"href": "#"
}
],
"disableAutoFocus": true
}) }}
Component status
- Phase
- To be reviewed
- Tested without JavaScript
- Yes
- Tested without CSS
- Yes
- Passed DAC audit
- Not yet audied
- Documentation complete
- No
How it works
Add links to all the form issues in the order in which they appear on the page.
When linking to checkboxes, radios and date input fields, add the ID of the first field in the list such as the first checkbox, the first radio item or the day field of the date input.
Take a look at the example form with errors.