{% extends 'layout.html.twig' %}

{% block body %}
  <div class="row list">
    <div class="col-md-4 col-sm-12">
    {% for element in liste %}
      <div class="col-sm-6">
        <a href="/{{ type }}/{{ element.id }}">{{ element.name }}</a>
      </div>
      <div class="col-sm-6">
        <form action="/{{ type }}/delete" method="post">
          <input type="hidden" id="_method" name="_method" value="DELETE" />
          <input type="hidden" name="id" value="{{ element.id }}" />
          <button type="submit" title="{{ element.name }} löschen" class="btn btn-default btn-delete btn-xs">
            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
          </button>
        </form>
      </div>
      {% if loop.index == (liste|length / 3)|round(0, 'ceil') or loop.index == (liste|length * 2 / 3)|round(0, 'ceil') %}
        </div>
        <div class="col-md-4 col-sm-12">
      {% endif %}

    {% endfor %}
    </div>
  </div>
  <div class="row">
    <div class="col-sm-12">
      {% set text = 'Neuen ' ~ type | capitalize ~ ' anlegen' %}
      {% if button_text is defined %}
        {% set text = button_text %}
      {% endif %}
      <a href="/{{ type }}/add" class="btn btn-default">{{ text }}</a>
    </div>
  </div>
{% endblock %}
