{% extends "base.html" %}
{% load wagtailcore_tags dsfr_tags i18n honeypot_tags static %}

{% block extra_css %}
  <link rel="stylesheet" href="{% static 'css/honeypot.css' %}">
{% endblock extra_css %}

{% block title %}
  <title>{{ page.seo_title|default:page.title }} — {{ settings.sites_conformes_content_manager.CmsDsfrConfig.site_title }}</title>
{% endblock title %}

{% block content %}
  {% translate "Submit form" as submit_form %}
  <div class="fr-container fr-pt-4w">
    {% include "sites_conformes_content_manager/blocks/breadcrumbs.html" %}
    <h1>{{ page.title }}</h1>
  </div>

  {% include "sites_conformes_content_manager/blocks/messages.html" %}

  <div class="fr-container fr-pb-6w">
    {{ page.intro|richtext }}

    <form action="{% pageurl page %}" method="post" autocomplete="on">
      <div class="fr-fieldset__element">
        {% if page.all_fields_required %}
          <p class="fr-text--sm">{% translate "All fields are mandatory." %}</p>
        {% else %}
          <p class="fr-text--sm">{% translate "Fields marked with an asterisk (*) are mandatory." %}</p>
        {% endif %}
      </div>

      {% csrf_token %}
      {% if form.non_field_errors %}
        <section class="fr-my-4v fr-input-group fr-input-group--error">
          {{ form.non_field_errors }}
        </section>
      {% endif %}

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

      {% for field in form.visible_fields %}
        <div class="fr-fieldset__element">{% dsfr_form_field field %}</div>
      {% endfor %}

      {% honeypot_fields page.honeypot %}
      <div class="fr-fieldset__element">
        <input class="fr-btn" type="submit" value="{{ submit_form }}" />
      </div>
    </form>
  </div>
{% endblock content %}

{% block extra_js %}
  <script src="{% static 'js/honeypot.js' %}"></script>
{% endblock extra_js %}
