{% extends "base.html" %}

{% load wagtailcore_tags wagtailimages_tags %}
{% load i18n %}

{% block content %}
    <h1>{{ page.title }}</h1>
    <p class="meta">{{ page.date }}</p>
    {% if form %}
        {{form.errors}}
        <div>{{ page.intro|richtext }}</div>
        <form enctype="multipart/form-data" action="{% pageurl page %}" method="POST">
            {% csrf_token %}
            {% for field in form %}
                {% if field.is_hidden %}
                    <!--Empty space for reason, we don't want to show anything on empty fields-->
                    {{field}}
                {% else %}
                    <div class="form-group mt-3">
                        <label for="{{field.id}}" class="form-label">
                            {% trans field.label %}
                        </label>
                            {{field}}
                        <small id="emailHelp" class="form-text text-muted">
                            {% trans field.help_text %}
                        </small>
                        {% if field.error %}
                            {{error}}
                        {% endif %}
                    </div>
                {% endif %}
            {% endfor %}
            <div class="text-end mt-3">
                <input class="btn btn-lg btn-success" type="submit" value='{% trans "Submit" %}'>
            </div> 
        </form>
    {% else %}
        <div>You can fill in the from only one time.</div>
    {% endif %}
{% endblock %}
