mirror of https://github.com/django/django.git
Fixed #27712 -- Reallowed Input widget's attrs argument to set the input type.
Regression in b52c73008a
.
This commit is contained in:
parent
95f434e2b9
commit
6872ce2266
|
@ -268,6 +268,7 @@ class Input(Widget):
|
||||||
|
|
||||||
def __init__(self, attrs=None):
|
def __init__(self, attrs=None):
|
||||||
if attrs is not None:
|
if attrs is not None:
|
||||||
|
attrs = attrs.copy()
|
||||||
self.input_type = attrs.pop('type', self.input_type)
|
self.input_type = attrs.pop('type', self.input_type)
|
||||||
super(Input, self).__init__(attrs)
|
super(Input, self).__init__(attrs)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
from django.forms.widgets import Input
|
||||||
|
|
||||||
|
from .base import WidgetTest
|
||||||
|
|
||||||
|
|
||||||
|
class InputTests(WidgetTest):
|
||||||
|
|
||||||
|
def test_attrs_with_type(self):
|
||||||
|
attrs = {'type': 'date'}
|
||||||
|
widget = Input(attrs)
|
||||||
|
self.check_html(widget, 'name', 'value', '<input type="date" name="name" value="value" />')
|
||||||
|
# reuse the same attrs for another widget
|
||||||
|
self.check_html(Input(attrs), 'name', 'value', '<input type="date" name="name" value="value" />')
|
||||||
|
attrs['type'] = 'number' # shouldn't change the widget type
|
||||||
|
self.check_html(widget, 'name', 'value', '<input type="date" name="name" value="value" />')
|
Loading…
Reference in New Issue