mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-04 02:03:32 +02:00
updated clean in form
This commit is contained in:
parent
ea043bf504
commit
06a2e39c12
1 changed files with 6 additions and 13 deletions
|
@ -587,19 +587,12 @@ class OtherContactsForm(RegistrarForm):
|
||||||
|
|
||||||
# Override clean in order to correct validation logic
|
# Override clean in order to correct validation logic
|
||||||
def clean(self):
|
def clean(self):
|
||||||
# NOTE: using self.cleaned_data directly apparently causes a CORS error
|
|
||||||
cleaned = super().clean()
|
|
||||||
form_is_empty = all(v is None or v == "" for v in cleaned.values())
|
|
||||||
|
|
||||||
# NOTE: Phone number and email do NOT show up in cleaned values.
|
form_is_empty = True
|
||||||
# I have spent hours tyring to figure out why, but have no idea...
|
for name, field in self.fields.items():
|
||||||
# so for now we will grab their values from the raw data...
|
value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))
|
||||||
for i in self.data:
|
if value is not None and value != "":
|
||||||
if "phone" in i or "email" in i:
|
form_is_empty = False
|
||||||
# check if it has data
|
|
||||||
field_value = self.data.get(i)
|
|
||||||
# update the bool on whether the form is actually empty
|
|
||||||
form_is_empty = field_value == "" or field_value is None
|
|
||||||
|
|
||||||
if form_is_empty:
|
if form_is_empty:
|
||||||
# clear any errors raised by the form fields
|
# clear any errors raised by the form fields
|
||||||
|
@ -613,7 +606,7 @@ class OtherContactsForm(RegistrarForm):
|
||||||
if field in self.errors:
|
if field in self.errors:
|
||||||
del self.errors[field]
|
del self.errors[field]
|
||||||
|
|
||||||
return cleaned
|
return self.cleaned_data
|
||||||
|
|
||||||
|
|
||||||
class BaseOtherContactsFormSet(RegistrarFormSet):
|
class BaseOtherContactsFormSet(RegistrarFormSet):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue