Explorar o código

Fixes #5466: Fix validation for required custom fields

Jeremy Stretch %!s(int64=5) %!d(string=hai) anos
pai
achega
34643f536e
Modificáronse 2 ficheiros con 3 adicións e 2 borrados
  1. 1 0
      docs/release-notes/version-2.10.md
  2. 2 2
      netbox/extras/forms.py

+ 1 - 0
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
 * [#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
 * [#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
 * [#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
 
 
 ---
 ---
 
 

+ 2 - 2
netbox/extras/forms.py

@@ -46,13 +46,13 @@ class CustomFieldModelForm(forms.ModelForm):
             # Annotate the field in the list of CustomField form fields
             # Annotate the field in the list of CustomField form fields
             self.custom_fields.append(field_name)
             self.custom_fields.append(field_name)
 
 
-    def save(self, commit=True):
+    def clean(self):
 
 
         # Save custom field data on instance
         # Save custom field data on instance
         for cf_name in self.custom_fields:
         for cf_name in self.custom_fields:
             self.instance.custom_field_data[cf_name[3:]] = self.cleaned_data.get(cf_name)
             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):
 class CustomFieldModelCSVForm(CSVModelForm, CustomFieldModelForm):