mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 11:24:10 -04:00
Split common checkbox methods off into mixin
This commit is contained in:
@@ -532,11 +532,7 @@ class RegisterUserFromOrgInviteForm(StripWhitespaceForm):
|
||||
auth_type = HiddenField('auth_type', validators=[DataRequired()])
|
||||
|
||||
|
||||
class govukCheckboxField(BooleanField):
|
||||
|
||||
def __init__(self, label='', validators=None, param_extensions=None, **kwargs):
|
||||
super(govukCheckboxField, self).__init__(label, validators, false_values=None, **kwargs)
|
||||
self.param_extensions = param_extensions
|
||||
class govukCheckboxesMixin:
|
||||
|
||||
def extend_params(self, params, extensions):
|
||||
items = None
|
||||
@@ -561,6 +557,13 @@ class govukCheckboxField(BooleanField):
|
||||
else:
|
||||
params['items'][idx].update(items[idx])
|
||||
|
||||
|
||||
class govukCheckboxField(govukCheckboxesMixin, BooleanField):
|
||||
|
||||
def __init__(self, label='', validators=None, param_extensions=None, **kwargs):
|
||||
super(govukCheckboxField, self).__init__(label, validators, false_values=None, **kwargs)
|
||||
self.param_extensions = param_extensions
|
||||
|
||||
# self.__call__ renders the HTML for the field by:
|
||||
# 1. delegating to self.meta.render_field which
|
||||
# 2. calls field.widget
|
||||
@@ -600,7 +603,7 @@ class govukCheckboxField(BooleanField):
|
||||
|
||||
|
||||
# based on work done by @richardjpope: https://github.com/richardjpope/recourse/blob/master/recourse/forms.py#L6
|
||||
class govukCheckboxesField(SelectMultipleField):
|
||||
class govukCheckboxesField(govukCheckboxesMixin, SelectMultipleField):
|
||||
|
||||
render_as_list = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user