Change init on BaseOtherContactsFormSet to show required on first form

This commit is contained in:
Rachid Mrad 2024-01-04 12:32:15 -05:00
parent 1d1496a8ed
commit 358aef1081
No known key found for this signature in database
GPG key ID: EF38E4CEC4A8F3CF

View file

@ -681,7 +681,17 @@ class BaseOtherContactsFormSet(RegistrarFormSet):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.formset_data_marked_for_deletion = False self.formset_data_marked_for_deletion = False
super().__init__(*args, **kwargs) self.application = kwargs.pop("application", None)
super(RegistrarFormSet, self).__init__(*args, **kwargs)
# quick workaround to ensure that the HTML `required`
# attribute shows up on required fields for any forms
# in the formset which have data already (stated another
# way: you can leave a form in the formset blank, but
# if you opt to fill it out, you must fill it out _right_)
for index in range(max(self.initial_form_count(), 1)):
self.forms[index].use_required_attribute = True
# self.forms[0].use_required_attribute = True
def pre_update(self, db_obj, cleaned): def pre_update(self, db_obj, cleaned):
"""Code to run before an item in the formset is saved.""" """Code to run before an item in the formset is saved."""