mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
Tweak form validation logic
This commit is contained in:
parent
472542b888
commit
1b696f58a5
@ -54,23 +54,20 @@ class InterfaceCommonForm(forms.Form):
|
|||||||
class ModuleCommonForm(forms.Form):
|
class ModuleCommonForm(forms.Form):
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super().clean()
|
super().clean()
|
||||||
|
|
||||||
# Skip form validation if field validation already found errors.
|
replicate_components = self.cleaned_data.get('replicate_components')
|
||||||
if self.errors:
|
adopt_components = self.cleaned_data.get('adopt_components')
|
||||||
return cleaned_data
|
device = self.cleaned_data.get('device')
|
||||||
|
module_type = self.cleaned_data.get('module_type')
|
||||||
replicate_components = cleaned_data.get("replicate_components")
|
module_bay = self.cleaned_data.get('module_bay')
|
||||||
adopt_components = cleaned_data.get("adopt_components")
|
|
||||||
device = cleaned_data.get('device')
|
|
||||||
module_type = cleaned_data.get('module_type')
|
|
||||||
module_bay = cleaned_data.get('module_bay')
|
|
||||||
|
|
||||||
if adopt_components:
|
if adopt_components:
|
||||||
self.instance._adopt_components = True
|
self.instance._adopt_components = True
|
||||||
|
|
||||||
# Bail out if we are not installing a new module or if we are not replicating components
|
# Bail out if we are not installing a new module or if we are not replicating components (or if
|
||||||
if self.instance.pk or not replicate_components:
|
# validation has already failed)
|
||||||
|
if self.errors or self.instance.pk or not replicate_components:
|
||||||
self.instance._disable_replication = True
|
self.instance._disable_replication = True
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user