{% extends "physics/base.html" %}
{% load crispy_forms_tags %}

{% block content %}
  <div class="container py-3">
    <div class="row">
      <div class="col-12">
        <h1>Add question</h1>
        <form method="post" novalidate>
          {% csrf_token %}
          {{ form.media }}

          {% if form.non_field_errors %}
            <div class="alert alert-danger">{{ form.non_field_errors }}</div>
          {% endif %}

          {% if form.helper %}
            {% crispy form form.helper %}
          {% else %}
            {% for field in form %}
              <div class="mb-3">
                {{ field.label_tag }}
                {{ field }}
                {% if field.help_text %}
                  <div class="form-text">{{ field.help_text }}</div>
                {% endif %}
                {% for error in field.errors %}
                  <div class="text-danger small">{{ error }}</div>
                {% endfor %}
              </div>
            {% endfor %}
          {% endif %}

          <button type="submit" class="btn btn-primary">Save</button>
          <a href="javascript:history.back()" class="btn btn-secondary">Cancel</a>
        </form>
      </div>
    </div>
  </div>
{% endblock %}
