form_page.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {% extends "base.html" %}
  2. {% block content %}
  3. <div class="container">
  4. <div class="row">
  5. <div class="col-md-12">
  6. <h1 class="index-header__title">{{ page.title }}</h1>
  7. </div>
  8. <div class="col-md-8 index-header__body-introduction">
  9. {% if page.intro %}
  10. <p class="intro">{{ page.intro|richtext }}</p>
  11. {% endif %}
  12. {% if page.body %}
  13. {{ page.body }}
  14. {% endif %}
  15. </div>
  16. </div>
  17. </div>
  18. <div class="container">
  19. <div class="row">
  20. <div class="col-md-8 form-page">
  21. {#
  22. 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:
  23. https://docs.djangoproject.com/en/3.2/topics/forms/#form-rendering-options
  24. #}
  25. <form action="{{ pageurl(page) }}" method="POST">
  26. <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf(request).csrf_token }}">
  27. {% if form.subject.errors %}
  28. <ol>
  29. {% for error in form.subject.errors %}
  30. <li><strong>{{ error|escape }}</strong></li>
  31. {% endfor %}
  32. </ol>
  33. {% endif %}
  34. {% for field in form %}
  35. <div class="form-page__field" aria-required={% if field.field.required %}"true"{% else %}"false"{% endif %}>
  36. {{ field.label_tag() }}{% if field.field.required %}<span class="required">*</span>{% endif %}
  37. {% if field.help_text %}
  38. <p class="help">{{ field.help_text }}</p>
  39. {% endif %}
  40. {{ field }}
  41. </div>
  42. {% endfor %}
  43. <input type="submit">
  44. </form>
  45. </div>
  46. </div>
  47. </div>
  48. {% endblock content %}