{% load crispy_forms_field %}

<div class="btn-group w-100 mb-3"
     role="group"
     aria-label="{{ field.label }}"
     _="on click
        if no <input[type='checkbox']:checked/> in me
          set nextCheckbox to the next <input[type='checkbox']/> from event.target within me with wrapping
          call nextCheckbox.click()
        end">
    {% for choice in field.field.choices %}
        <input type="checkbox"
               class="btn-check"
               name="{{ field.html_name }}"
               id="{{ field.html_name }}_{{ forloop.counter }}"
               value="{{ choice.0 }}"
               {% if choice.0 in field.value %}checked{% endif %}>
        <label class="btn btn-outline-dark w-100"
               for="{{ field.html_name }}_{{ forloop.counter }}">
            {{ choice.1 }}
        </label>
    {% endfor %}
</div>
