{% extends 'speeches/base_form_select2.html' %}
{% load staticfiles %}
{% load i18n %}

{% block title %}
{% if object %}
    {% trans 'Edit section' %}
{% else %}
    {% trans 'Add a section' %}
{% endif %}
{% endblock %}

{% block content %}

<div class="page-header">
  {% if object %}
    <h1>{% trans "Edit section" %}</h1>
  {% else %}
    <h1>{% trans "Add a section" %}</h1>
  {% endif %}
</div>

<form id="section-form" class="form-horizontal" method="post">
    {% if object %}
        {% trans "Update section" as submit %}
    {% else %}
        {% trans "Add section" as submit %}
    {% endif %}

    {% csrf_token %}

{% if form.non_field_errors %}
    <div class="error">
        {{ form.non_field_errors }}
    </div>
{% endif %}

{% for hidden in form.hidden_fields %}
    {{ hidden }}
{% endfor %}

{% for field in form.visible_fields %}
  {% if field.name != 'start_date' and field.name != 'start_time' %}
    <div class="row{% if field.errors %} error{% endif %}" id="{{ field.auto_id }}_controls">
      <div class="large-8 columns">
        {{ field.label_tag }}
        {{ field }}
      {% if field.errors %}
        <span class="error">{% for error in field.errors %}{{ error }}{% endfor %}</span>
      {% endif %}
      </div>
    </div>
  {% endif %}
{% endfor %}

  <div class="row">
      <div class="large-8 columns">
          <div class="row">
              <div class="small-7 column">
                  {% include "speeches/form-item.html" with field=form.start_date %}
              </div>
              <div class="small-5 column">
                  {% include "speeches/form-item.html" with field=form.start_time %}
              </div>
          </div>
      </div>
  </div>

<div class="form-actions">
    <input type="submit" id="section_submit" class="button" value="{{ submit }}">
</div>

</form>
{% endblock %}
