From 34643f536ee3d1ba3a75ea76e09769d20ded26ca Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 15 Dec 2020 15:56:42 -0500 Subject: [PATCH] Fixes #5466: Fix validation for required custom fields --- docs/release-notes/version-2.10.md | 1 + netbox/extras/forms.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-2.10.md b/docs/release-notes/version-2.10.md index 7667c92c9..9651cf6c4 100644 --- a/docs/release-notes/version-2.10.md +++ b/docs/release-notes/version-2.10.md @@ -10,6 +10,7 @@ * [#5461](https://github.com/netbox-community/netbox/issues/5461) - Rack Elevations throw reverse match exception * [#5463](https://github.com/netbox-community/netbox/issues/5463) - Back-to-back Circuit Termination throws AttributeError exception * [#5465](https://github.com/netbox-community/netbox/issues/5465) - Correct return URL when disconnecting a cable from a device +* [#5466](https://github.com/netbox-community/netbox/issues/5466) - Fix validation for required custom fields --- diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index eee54076b..932d07a4d 100644 --- a/netbox/extras/forms.py +++ b/netbox/extras/forms.py @@ -46,13 +46,13 @@ class CustomFieldModelForm(forms.ModelForm): # Annotate the field in the list of CustomField form fields self.custom_fields.append(field_name) - def save(self, commit=True): + def clean(self): # Save custom field data on instance for cf_name in self.custom_fields: self.instance.custom_field_data[cf_name[3:]] = self.cleaned_data.get(cf_name) - return super().save(commit) + return super().clean() class CustomFieldModelCSVForm(CSVModelForm, CustomFieldModelForm):