{% extends "deliver_grant_funding/grant_base.html" %}
{% from "govuk_frontend_jinja/components/back-link/macro.html" import govukBackLink %}

{% set page_title = "Question group add another options" %}
{% set type_constants = db_form.collection.type.constants %}
{% set active_item_identifier = type_constants.active_nav %}

{% block beforeContent %}
  {{
    govukBackLink({
      "text": "Back",
      "href": url_for("deliver_grant_funding.add_question_group_display_options", grant_id=grant.id, form_id=db_form.id, name=group_name, parent_id=parent.id if parent else None)
    })
  }}
{% endblock beforeContent %}

{% block content %}
  <div class="govuk-grid-row">
    <div class="govuk-grid-column-two-thirds">
      <span class="govuk-caption-l">{{ grant.name }}</span>
      <h1 class="govuk-heading-l govuk-!-margin-bottom-0">{{ form.question_group_is_add_another.label }}</h1>

      <form method="post" novalidate>
        {{ form.csrf_token }}
        {{
          form.question_group_is_add_another(params={
            "fieldset": {
              "legend": {
                "classes": "govuk-visually-hidden"
              }
            },
            "items": [
              {
                "hint": {
                  "text": "After adding their first answer we'll ask if they need to add another",
                }
              },
              {},
            ]
          })
        }}

        <div class="govuk-button-group">
          {{ form.submit(params={"text": "Add question group"}) }}

          {% set link = url_for("deliver_grant_funding.list_section_questions", grant_id=grant.id, form_id=db_form.id) if not parent else url_for('deliver_grant_funding.list_group_questions', grant_id=grant.id, group_id=parent.id) %}
          <a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">Cancel</a>
        </div>
      </form>
    </div>
  </div>
{% endblock content %}
