{% macro govukDateInput(params) %} {% from "govuk_frontend_jinja/macros/attributes.html" import govukAttributes %} {% from "govuk_frontend_jinja/components/error-message/macro.html" import govukErrorMessage %} {% from "govuk_frontend_jinja/components/fieldset/macro.html" import govukFieldset %} {% from "govuk_frontend_jinja/components/hint/macro.html" import govukHint %} {% from "govuk_frontend_jinja/components/input/macro.html" import govukInput %} {#- a record of other elements that we need to associate with the input using aria-describedby – for example hints or error messages -#} {% set ns = namespace() %} {% set ns.describedBy = params.fieldset.describedBy if params.fieldset and params.fieldset.describedBy else "" %} {#- fieldset is false by default -#} {% set hasFieldset = true if params.fieldset else false %} {%- if 'items' in params and params['items'] | length %} {% set dateInputItems = params['items'] %} {% else %} {% set dateInputItems = [ { 'name': "day", 'classes': "govuk-input--width-2" }, { 'name': "month", 'classes': "govuk-input--width-2" }, { 'name': "year", 'classes': "govuk-input--width-4" } ] %} {% endif %} {#- Capture the HTML so we can optionally nest it in a fieldset -#} {% set innerHtml %} {% if params.hint %} {% set hintId = params.id + "-hint" %} {% set ns.describedBy = ns.describedBy + " " + hintId if ns.describedBy else hintId %} {{ govukHint({ 'id': hintId, 'classes': params.hint.classes, 'attributes': params.hint.attributes, 'html': params.hint.html, 'text': params.hint.text }) | trim | indent(2) }} {% endif %} {% if params.errorMessage %} {% set errorId = params.id + "-error" %} {% set ns.describedBy = ns.describedBy + " " + errorId if ns.describedBy else errorId %} {{ govukErrorMessage({ 'id': errorId, 'classes': params.errorMessage.classes, 'attributes': params.errorMessage.attributes, 'html': params.errorMessage.html, 'text': params.errorMessage.text, 'visuallyHiddenText': params.errorMessage.visuallyHiddenText }) | trim | indent(2) }} {% endif %}