mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Force validation of individual objects within a MultiObjectField
This commit is contained in:
@ -570,6 +570,14 @@ class MultiObjectField(forms.Field):
|
||||
if value is None:
|
||||
return list()
|
||||
|
||||
for i, obj_data in enumerate(value, start=1):
|
||||
form = self.form(obj_data)
|
||||
if not form.is_valid():
|
||||
errors = [
|
||||
"Object {} {}: {}".format(i, field, errors) for field, errors in form.errors.items()
|
||||
]
|
||||
raise forms.ValidationError(errors)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user