DateFrameWidget: Improve dealing with required fields

This commit is contained in:
Raphael Michel
2023-02-06 13:15:22 +01:00
parent 90978e5cab
commit b3bcad38a8

View File

@@ -301,6 +301,8 @@ class DateFrameWidget(forms.MultiWidget):
def get_context(self, name, value, attrs):
ctx = super().get_context(name, value, attrs)
ctx['required'] = self.timeframe_choices[0][0] == 'unset'
ctx['widget']['subwidgets'][1]['attrs'].pop('required', None)
ctx['widget']['subwidgets'][2]['attrs'].pop('required', None)
return ctx