{% extends "dashboard/base.html" %}
{% load i18n %}
{% load crispy_forms_field %}

{% block content %}
<div class="row">
  <div class="col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
          <h3 class="no-margin"><i class="fa fa-phone"></i> {% trans "Request fields" %}</h3>
         </div>
            <div class="panel-body">
              <div class="table-responsive">
                <div class="table-container">
                  <table class="text-center table table-bordered table-striped table-hover" >
                    <thead class"align-center">
                        <tr>
                        <th class="text-center">{% trans "Fieldname" %}</th>
                        <th class="text-center">{% trans "Type" %}</th>
                        <th class="text-center">{% trans "RequestType" %}</th>
                        <th class="text-center">{% trans "Choices" %}</th>
                        <th class="text-center">{% trans "Required" %}</th>
                        <th class="text-center">{% trans "Delete" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for field in object_list %}
                        <tr>
                          <td>{{field.fieldname}}</td>
                          <td>{{field.type}}</td>
                          <td>{{field.request_type}}</td>
                          <td>{{field.choices}}</td>
                          <td>{{field.required}}</td>
                          <td><a href={% url "request.views.field-delete" pk=field.pk %}>
                            <i class="fa fa-times"></i></a>
                          </td>
                        </tr>
                        {% endfor %}
                        <tr>
                        <form action={% url 'request.views.request-field-add' %} method="post">
                          {% csrf_token %}
                          {% for field in add_form %}
                              <td> {% crispy_field field %}</td>
                          {% endfor %}
                        <td><button type="submit" class="btn btn-sm btn-success">{% trans "Add" %}</button></td>
                      </form>
                      </tr>
                      </tbody>
                  </table>
                </div>
              </div> <!-- .table-responsive -->
            </div> <!-- .panel-body -->
          </div>
        </div>
      </div>

{% endblock %}
