From 5f425e6fd848466331acf49ee2c9c38954b7899e Mon Sep 17 00:00:00 2001 From: sterliakov Date: Wed, 16 Feb 2022 14:08:14 +0300 Subject: [PATCH] Remove attribute for html5 compliance --- phonenumber_field/widgets.py | 2 ++ tests/test_widgets.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/phonenumber_field/widgets.py b/phonenumber_field/widgets.py index 30368624..44dc23f4 100644 --- a/phonenumber_field/widgets.py +++ b/phonenumber_field/widgets.py @@ -43,6 +43,8 @@ def __init__(self, initial=None): super().__init__(choices=sorted(choices, key=lambda item: item[1])) def get_context(self, name, value, attrs): + attrs = (attrs or {}).copy() + attrs.pop("maxlength", None) return super().get_context(name, value or self.initial, attrs) diff --git a/tests/test_widgets.py b/tests/test_widgets.py index b627e734..b5367ba1 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -33,6 +33,12 @@ def test_after_translation_deactivate_all(self): '', html) + class PhoneNumberInternationalFallbackWidgetTest(SimpleTestCase): def test_fallback_widget_switches_between_national_and_international(self):