form_page.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {% extends "base.html" %}
  2. {% load wagtailcore_tags navigation_tags wagtailimages_tags %}
  3. {% block content %}
  4. {% include "base/include/header-hero.html" %}
  5. <div class="container">
  6. <div class="row">
  7. <div class="col-md-8">
  8. {% if page.intro %}
  9. <p class="intro">{{ page.intro|richtext }}</p>
  10. {% endif %}
  11. {% if page.body %}
  12. {{ page.body }}
  13. {% endif %}
  14. </div>
  15. </div>
  16. </div>
  17. <div class="container">
  18. <div class="row">
  19. <div class="col-md-8 form-page">
  20. {% comment %}
  21. You could render your form using a Django rendering shortcut such as `{{ form.as_p }}` but that will tend towards unsemantic code, and make it difficult to style. You can read more on Django form at:
  22. https://docs.djangoproject.com/en/1.10/topics/forms/#form-rendering-options
  23. {% endcomment %}
  24. <form action="{% pageurl page %}" method="POST" role="form">
  25. {% csrf_token %}
  26. {% if form.subject.errors %}
  27. <ol role="alertdialog">
  28. {% for error in form.subject.errors %}
  29. <li role="alert"><strong>{{ error|escape }}</strong></li>
  30. {% endfor %}
  31. </ol>
  32. {% endif %}
  33. {% for field in form %}
  34. <div class="fieldWrapper" aria-required={% if field.field.required %}"true"{% else %}"false"{% endif %}>
  35. {{ field.label_tag }}{% if field.field.required %}<span class="required">*</span>{% endif %}
  36. {{ field }}
  37. {% if field.help_text %}
  38. <p class="help">{{ field.help_text|safe }}</p>
  39. {% endif %}
  40. </div>
  41. {% endfor %}
  42. <input type="submit">
  43. </form>
  44. </div>
  45. </div>
  46. </div>
  47. {% endblock content %}