{% macro digitalmarketplaceComplianceCommunicationAttachments(params) %} {%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%} {%- from "govuk_frontend_jinja/components/fieldset/macro.html" import govukFieldset -%} {%- from "digitalmarketplace_frontend_jinja/components/compliance-communication-attachment-row/macro.html" import digitalmarketplaceComplianceCommunicationAttachmentRow -%} {% set number_of_attachments = params.number_of_attachments or 3 %} {% call govukFieldset({ "legend": { "text": "Add an attachment", "classes": "govuk-fieldset__legend--m" }, "attributes": { "data-module": "dm-compliance-communication-attachments", "data-max-number-of-attachments": number_of_attachments } }) %}

{% if params.hint %} {{ params.hint.html | safe | trim | indent(2) if params.hint.html else params.hint.text }} {% else %} You can add up to {{ number_of_attachments }} attachments {% endif %}

{{ digitalmarketplaceComplianceCommunicationAttachmentRow({ "form": { "attachment_file_99": { "name": "attachment_file_99", "question": params.form.attachment_file_0.question, "hint": params.form.attachment_file_0.hint }, "attachment_required_99": { "name": "attachment_required_99", "question": params.form.attachment_required_0.question, "data": None } }, "index": 99, "template": True }) }}
{% for index in range(number_of_attachments) %} {{ digitalmarketplaceComplianceCommunicationAttachmentRow({ "form": params.form, "index": index }) }} {% endfor %}
{{ govukButton({ "html": 'Add attachment (0 remaining)', "classes": "govuk-button--secondary dm-compliance-communication__attachments-add govuk-visually-hidden", "type": "button", "attributes": { "tabindex": "-1" } }) }} {% endcall %} {% endmacro %}