Add GovukIntegerField - extends IntegerField

This commit is contained in:
Tom Byers
2020-08-07 10:30:46 +01:00
parent 3953e67499
commit 97ddc7923a

View File

@@ -325,6 +325,19 @@ class GovukDateField(DateField):
return govuk_field_widget(self, field, param_extensions=param_extensions, **kwargs)
class GovukIntegerField(IntegerField):
def __init__(self, label='', validators=None, param_extensions=None, **kwargs):
super(GovukIntegerField, 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):
return govuk_field_widget(self, field, param_extensions=param_extensions, **kwargs)
class SMSCode(GovukTextInputField):
validators = [
DataRequired(message='Cannot be empty'),