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 |
Required. |
headingLevel | number |
Required. |
items | array |
Required. |
disableAutoFocus | boolean | |
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. |
href | string |
Required. |
{% 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
}) }}
Status
- Status
- Ready for production
- Tested without JavaScript
- Yes
- Tested without CSS
- Yes
- Passed DAC audit
- Not yet audied
- Analytics integrated
- In development
- 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.