1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #5851 -- Allowed specifying different HTML attrs for SplitDateTimeWidget subwidgets.

Thanks Tim Graham and Nick Pope for review.
This commit is contained in:
Mariusz Felisiak
2017-01-13 12:48:30 +01:00
committed by Tim Graham
parent 3a148f958d
commit 0034e9af18
5 changed files with 52 additions and 9 deletions

View File

@@ -40,3 +40,15 @@ class SplitHiddenDateTimeWidgetTest(WidgetTest):
<input type="hidden" name="date_1" value="12:51:00" />
"""
))
def test_constructor_different_attrs(self):
html = (
'<input type="hidden" class="foo" value="2006-01-10" name="date_0" />'
'<input type="hidden" class="bar" value="07:30:00" name="date_1" />'
)
widget = SplitHiddenDateTimeWidget(date_attrs={'class': 'foo'}, time_attrs={'class': 'bar'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
widget = SplitHiddenDateTimeWidget(date_attrs={'class': 'foo'}, attrs={'class': 'bar'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
widget = SplitHiddenDateTimeWidget(time_attrs={'class': 'bar'}, attrs={'class': 'foo'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)