{% extends 'base.html' %}
{% load bootstrap4 jugemaj %}

{% block content %}
<form action="" method="post" class="form-horizontal">
  {% csrf_token %}
  {% bootstrap_form formset.management_form %}
  {% for form in formset %}
  <div class="form-group">
    <label class="col-md-3 control-label">{{ form.hidden_fields.0.value|candidate:candidates }}:</label>
    <div class="col-md-9">
      {% for field in form.hidden_fields %}{{ field }}{% endfor %}
      {% for field in form.visible_fields %}
        {% for radio in field %}
          {% if not forloop.first %}
          <div class="btn-group" data-toggle="buttons">
            <label class="btn btn-primary{% if radio.data.attrs.checked %} active{% endif %}">
              {{ radio.tag }} {{ radio.choice_label }}
            </label>
          </div>
          {% endif %}
        {% endfor %}
      {% endfor %}
    </div>
  </div>
  {% endfor %}

  {% buttons layout="horizontal" %}
  <button type="submit" class="btn btn-primary">Ok !</button>
  {% endbuttons %}
</form>
{% endblock %}
