From 01f84d544370653c319794eb177b2c93a70ddd43 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 9 Jul 2020 12:04:18 +0100 Subject: [PATCH] Convert checkboxes for broadcast areas Includes removal of MultiCheckboxField due to it no longer being used elsewhere in this file. --- app/main/forms.py | 10 +++------- app/templates/views/broadcast/areas.html | 5 ++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 0134a0274..e34eeda40 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -38,7 +38,6 @@ from wtforms import ( ) from wtforms.fields.html5 import EmailField, SearchField, TelField from wtforms.validators import URL, DataRequired, Length, Optional, Regexp -from wtforms.widgets import CheckboxInput, ListWidget from app import format_thousands from app.main.validators import ( @@ -118,11 +117,6 @@ def get_next_days_until(until): ] -class MultiCheckboxField(SelectMultipleField): - widget = ListWidget(prefix_label=False) - option_widget = CheckboxInput() - - class RadioField(WTFormsRadioField): def __init__( @@ -2135,11 +2129,13 @@ class AcceptAgreementForm(StripWhitespaceForm): class BroadcastAreaForm(StripWhitespaceForm): - areas = MultiCheckboxField('Choose areas to broadcast to') + areas = govukCheckboxesField('Choose areas to broadcast to') def __init__(self, choices, *args, **kwargs): super().__init__(*args, **kwargs) self.areas.choices = choices + self.areas.render_as_list = True + self.areas.param_extensions = {'fieldset': {'legend': {'classes': 'govuk-visually-hidden'}}} @classmethod def from_library(cls, library): diff --git a/app/templates/views/broadcast/areas.html b/app/templates/views/broadcast/areas.html index 5020b587c..9ed0a38e8 100644 --- a/app/templates/views/broadcast/areas.html +++ b/app/templates/views/broadcast/areas.html @@ -1,6 +1,5 @@ {% from "components/page-header.html" import page_header %} {% from "components/page-footer.html" import sticky_page_footer %} -{% from "components/checkbox.html" import checkboxes %} {% from "components/form.html" import form_wrapper %} {% from "components/live-search.html" import live_search %} @@ -17,10 +16,10 @@ back_link=url_for('.choose_broadcast_library', service_id=current_service.id, broadcast_message_id=broadcast_message.id), )}} - {{ live_search(target_selector='.multiple-choice', show=show_search_form, form=search_form, label='Search by name') }} + {{ live_search(target_selector='.govuk-checkboxes__item', show=show_search_form, form=search_form, label='Search by name') }} {% call form_wrapper() %} - {{ checkboxes(form.areas, hide_legend=True) }} + {{ form.areas }} {{ sticky_page_footer('Add to broadcast') }} {% endcall %}