Use a macro for form tags

This will stop us repeatedly forgetting to add `novalidate` and
`autocomplete='off'` to our forms (which is how most of them are set
up).

It uses sensible defaults, based on how we most-commonly configure
forms:
- most of our forms are `post`ed (but this can be overridden)
- `autocomplete` should only be enabled where it makes sense, otherwise
  it’s more annoying than useful (but this can be overriden)
- we should never be using HTML5 form validation because our own error
  styles and messages are better
This commit is contained in:
Chris Hill-Scott
2018-09-19 12:39:36 +01:00
parent 5ab876aeab
commit d9da219b7e
72 changed files with 257 additions and 170 deletions

View File

@@ -5,6 +5,7 @@
{% from "components/big-number.html" import big_number, big_number_with_status %}
{% from "components/message-count-label.html" import message_count_label %}
{% from "components/table.html" import mapping_table, field, stats_fields, row_group, row, right_aligned_field_heading, hidden_field_heading, text_field %}
{% from "components/form.html" import form_wrapper %}
{% macro stats_fields(channel, data) -%}
@@ -102,13 +103,13 @@
<details>
<summary>Apply filters</summary>
<form autocomplete="off" method="get">
{% call form_wrapper(method="get") %}
{{ textbox(form.start_date, hint="Enter start date in format YYYY-MM-DD") }}
{{ textbox(form.end_date, hint="Enter end date in format YYYY-MM-DD") }}
{{ checkbox(form.include_from_test_key) }}
</br>
<button type="submit" class="button">Filter</button>
</form>
{% endcall %}
</details>
{% include "views/platform-admin/_global_stats.html" %}