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

Fixes #2414: Tags field missing from device/VM component creation forms

This commit is contained in:
Jeremy Stretch
2018-09-28 16:26:08 -04:00
parent 020b5ea870
commit 15babeb584
6 changed files with 16 additions and 21 deletions

View File

@@ -710,24 +710,14 @@ class ComponentCreateView(View):
if form.is_valid():
new_components = []
data = deepcopy(form.cleaned_data)
data = deepcopy(request.POST)
data[self.parent_field] = parent.pk
for name in form.cleaned_data['name_pattern']:
# Initialize data for the individual component form
component_data = {
self.parent_field: parent.pk,
'name': name,
}
# Replace objects with their primary key to keep component_form.clean() happy
for k, v in data.items():
if hasattr(v, 'pk'):
component_data[k] = v.pk
else:
component_data[k] = v
component_form = self.model_form(component_data)
# Initialize the individual component form
data['name'] = name
component_form = self.model_form(data)
if component_form.is_valid():
new_components.append(component_form)