{% load i18n %}

<form method="post" id="newsletter_subscription" action="{% url 'newsletter_subscription' %}" class="form">
    {% if success %}
        <p class="section__text form__success">
            {% trans 'Ihre Angaben wurden erfolgreich übermittelt. Vielen Dank!' %}
        </p>
    {% else %}
        {% if form.non_field_errors %}
            {% for error in form.non_field_errors %}
                <p class="form__errors">{{ error }}</p>
            {% endfor %}
        {% endif %}

        {% for field in form %}
            <div class="form__field reveal_self reveal reveal_animation">
                {{ field }}

                {% if field.errors %}
                    <p class="form__field__errors">
                        {% for error in field.errors %}
                            {{ error }}{% if not forloop.last %}<br>{% endif %}
                        {% endfor %}
                    </p>
                {% endif %}

                {% if field.help_text %}
                    <p class="form__field__help_text">{{ field.help_text }}</p>
                {% endif %}
            </div>
        {% endfor %}

        {% csrf_token %}
        {% for field in form.hidden_fields %}
            {{ field }}
        {% endfor %}

        <div class="form__submit reveal_self reveal reveal_animation">
            <button type="submit" class="button">
                <span class="button__icon">{% include 'project/assets/arrow-right-long.svg' %}</span>
                <span class="button__text">{% trans 'Absenden' %}</span>
            </button>
        </div>

    {% endif %}
</form>