1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #5466: Fix validation for required custom fields

This commit is contained in:
Jeremy Stretch
2020-12-15 15:56:42 -05:00
parent 6a3dab0142
commit 34643f536e
2 changed files with 3 additions and 2 deletions

View File

@ -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):