Use govukButton to display 'Preview this alert' button

There are no changes to appearance of the 'Preview this alert' button or
what it does, but this stops a CSRF token appearing in the query
string when you click the button. We don't need a CSRF token - it's
a simple GET request which doesn't change any data. Before, we had a form
with `method="get"` but because we were using a `page_footer` a CSRF
token was being added.

We can replace both the `<form>` element and `page_footer` with a
`govukButton`. This means that we make a GET request with no CSRF token
without changing the appearance of the button.
This commit is contained in:
Katie Smith
2022-02-25 16:12:31 +00:00
parent 05b8fd7c01
commit 22d25b7a1c

View File

@@ -63,9 +63,12 @@
{% if broadcast_message.areas %}
{{ map(broadcast_message) }}
<form action="{{ url_for('.preview_broadcast_message', service_id=current_service.id, broadcast_message_id=broadcast_message.id) }}" method="get" class="govuk-!-margin-top-1">
{{ page_footer('Preview this alert') }}
</form>
{{ govukButton({
"element": "a",
"text": "Preview this alert",
"href": url_for('.preview_broadcast_message', service_id=current_service.id, broadcast_message_id=broadcast_message.id),
"classes": "govuk-button"
}) }}
{% endif %}
{% endblock %}