1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #31012 -- Reverted "Fixed #29056 -- Fixed HTML5 validation of required SelectDateWidget."

This reverts commit f038214d91.

The initial issue was incorrect. Django 2.2, and before, did not
generate invalid HTML as reported. With f03821 in place invalid HTML
was generated.

Thanks to Kevin Brown for follow-up report and investigation.
This commit is contained in:
Carlton Gibson
2019-11-21 20:53:31 +01:00
committed by Mariusz Felisiak
parent 664c98f1f8
commit ee4a19053a
3 changed files with 3 additions and 59 deletions

View File

@@ -979,11 +979,7 @@ class SelectDateWidget(Widget):
date_context['year'] = self.select_widget(attrs, choices=year_choices).get_context(
name=year_name,
value=context['widget']['value']['year'],
attrs={
**context['widget']['attrs'],
'id': 'id_%s' % year_name,
'placeholder': _('Year') if self.is_required else False,
},
attrs={**context['widget']['attrs'], 'id': 'id_%s' % year_name},
)
month_choices = list(self.months.items())
if not self.is_required:
@@ -992,11 +988,7 @@ class SelectDateWidget(Widget):
date_context['month'] = self.select_widget(attrs, choices=month_choices).get_context(
name=month_name,
value=context['widget']['value']['month'],
attrs={
**context['widget']['attrs'],
'id': 'id_%s' % month_name,
'placeholder': _('Month') if self.is_required else False,
},
attrs={**context['widget']['attrs'], 'id': 'id_%s' % month_name},
)
day_choices = [(i, i) for i in range(1, 32)]
if not self.is_required:
@@ -1005,11 +997,7 @@ class SelectDateWidget(Widget):
date_context['day'] = self.select_widget(attrs, choices=day_choices,).get_context(
name=day_name,
value=context['widget']['value']['day'],
attrs={
**context['widget']['attrs'],
'id': 'id_%s' % day_name,
'placeholder': _('Day') if self.is_required else False,
},
attrs={**context['widget']['attrs'], 'id': 'id_%s' % day_name},
)
subwidgets = []
for field in self._parse_date_fmt():