Skip to content

Commit

Permalink
Set PhoneNumberInternationalFallbackWidget input_type to tel
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisfreitag committed Aug 28, 2022
1 parent 1f012e4 commit 290e82b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions phonenumber_field/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class PhoneNumberInternationalFallbackWidget(TextInput):
an international number will fall back to international format
"""

input_type = "tel"

def __init__(self, region=None, attrs=None):
if region is None:
region = getattr(settings, "PHONENUMBER_DEFAULT_REGION", None)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ def test_fallback_widget_switches_between_national_and_international(self):
de_widget = PhoneNumberInternationalFallbackWidget(region="DE")
self.assertHTMLEqual(
gb_widget.render("number", number),
'<input name="number" type="text" value="01606 75178" />',
'<input name="number" type="tel" value="01606 75178" />',
)
self.assertHTMLEqual(
de_widget.render("number", number),
'<input name="number" type="text" value="+44 1606 75178" />',
'<input name="number" type="tel" value="+44 1606 75178" />',
)

# If there's been a validation error, the value should be included verbatim
self.assertHTMLEqual(
gb_widget.render("number", "error"),
'<input name="number" type="text" value="error" />',
'<input name="number" type="tel" value="error" />',
)

0 comments on commit 290e82b

Please sign in to comment.