mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-10 04:14:37 -04:00
Add GovukSearchField - extends SearchField
This commit is contained in:
@@ -294,6 +294,23 @@ class GovukEmailField(EmailField):
|
||||
return govuk_field_widget(self, field, type="email", param_extensions=params, **kwargs)
|
||||
|
||||
|
||||
class GovukSearchField(SearchField):
|
||||
def __init__(self, label='', validators=None, param_extensions=None, **kwargs):
|
||||
super(GovukSearchField, self).__init__(label, validators, **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
|
||||
# this bypasses that by making self.widget a method with the same interface as widget.__call__
|
||||
def widget(self, field, param_extensions=None, **kwargs):
|
||||
|
||||
params = {"classes": "govuk-!-width-full"} # email addresses don't need to be spellchecked
|
||||
if param_extensions:
|
||||
params.update(param_extensions)
|
||||
return govuk_field_widget(self, field, type="search", param_extensions=params, **kwargs)
|
||||
|
||||
|
||||
class SMSCode(StringField):
|
||||
validators = [
|
||||
DataRequired(message='Cannot be empty'),
|
||||
|
||||
Reference in New Issue
Block a user