mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-23 03:58:45 -06:00
fix(dcim): Avoid clearing scope on clone
ScopedForm._set_scoped_values() cleared initial['scope'] whenever the scope_type differed from the instance value. During cloning (unsaved instance), this runs on the initial GET and wipes the pre-filled scope, forcing the user to re-select it. Only clear the scope when editing an existing object (instance.pk set) and the scope type has actually changed. Fixes #21202
This commit is contained in:
@@ -75,7 +75,7 @@ class ScopedForm(forms.Form):
|
|||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.instance and scope_type_id != self.instance.scope_type_id:
|
if self.instance and self.instance.pk and scope_type_id != self.instance.scope_type_id:
|
||||||
self.initial['scope'] = None
|
self.initial['scope'] = None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user