{% macro govukRadios(params) %} {% 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/label/macro.html" import govukLabel %} {#- If an id 'prefix' is not passed, fall back to using the name attribute instead. We need this for error messages and hints as well -#} {% set idPrefix = params.idPrefix if params.idPrefix else params.name %} {#- a record of other elements that we need to associate with the input using aria-describedby – for example hints or error messages -#} {% set describedBy = params.fieldset.describedBy if params.fieldset and params.fieldset.describedBy else "" %} {% set isConditional = False %} {% for item in params['items'] %} {% if item.conditional and item.conditional.html %} {% set isConditional = True %} {% endif %} {% endfor %} {#- Capture the HTML so we can optionally nest it in a fieldset -#} {% set innerHtml %} {% if params.hint %} {% set hintId = idPrefix + '-hint' %} {% set describedBy = describedBy + ' ' + hintId if describedBy else hintId %} {{ govukHint({ 'id': hintId, 'classes': (params.hint.classes if params.hint and params.hint.classes), 'attributes': params.hint.attributes, 'html': params.hint.html, 'text': params.hint.text }) | trim }} {% endif %} {% if params.errorMessage %} {% set errorId = idPrefix + '-error' %} {% set describedBy = describedBy + ' ' + errorId if 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 }} {% endif %}