diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 801067ee38..a2f674fcdd 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -808,9 +808,12 @@ class MultiWidget(Widget):
value = self.decompress(value)
final_attrs = context['widget']['attrs']
+ input_type = final_attrs.pop('type', None)
id_ = final_attrs.get('id')
subwidgets = []
for i, widget in enumerate(self.widgets):
+ if input_type is not None:
+ widget.input_type = input_type
widget_name = '%s_%s' % (name, i)
try:
widget_value = value[i]
diff --git a/tests/forms_tests/widget_tests/test_multiwidget.py b/tests/forms_tests/widget_tests/test_multiwidget.py
index a7cd8e0d5d..bf9ef38a6b 100644
--- a/tests/forms_tests/widget_tests/test_multiwidget.py
+++ b/tests/forms_tests/widget_tests/test_multiwidget.py
@@ -118,6 +118,19 @@ class MultiWidgetTest(WidgetTest):
''
))
+ def test_constructor_attrs_with_type(self):
+ attrs = {'type': 'number'}
+ widget = MyMultiWidget(widgets=(TextInput, TextInput()), attrs=attrs)
+ self.check_html(widget, 'code', ['1', '2'], html=(
+ ''
+ ''
+ ))
+ widget = MyMultiWidget(widgets=(TextInput(attrs), TextInput(attrs)), attrs={'class': 'bar'})
+ self.check_html(widget, 'code', ['1', '2'], html=(
+ ''
+ ''
+ ))
+
def test_value_omitted_from_data(self):
widget = MyMultiWidget(widgets=(TextInput(), TextInput()))
self.assertIs(widget.value_omitted_from_data({}, {}, 'field'), True)