Fixes #1158: Exception thrown when creating a device component with an invalid name

This commit is contained in:
Jeremy Stretch 2017-05-10 11:23:54 -04:00
parent 088f75ba0c
commit 83688fceb7

View File

@ -105,6 +105,9 @@ class ComponentCreateView(View):
new_components.append(component_form.save(commit=False))
else:
for field, errors in component_form.errors.as_data().items():
# Assign errors on the child form's name field to name_pattern on the parent form
if field == 'name':
field = 'name_pattern'
for e in errors:
form.add_error(field, u'{}: {}'.format(name, ', '.join(e)))