mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #1265: Fix console/power/interface connection validation when selecting a device via live search
This commit is contained in:
@ -1594,9 +1594,10 @@ class InterfaceConnectionForm(BootstrapMixin, ChainedFieldsMixin, forms.ModelFor
|
||||
]
|
||||
|
||||
# Mark connected interfaces as disabled
|
||||
self.fields['interface_b'].choices = [
|
||||
(iface.id, {'label': iface.name, 'disabled': iface.is_connected}) for iface in self.fields['interface_b'].queryset
|
||||
]
|
||||
if self.data.get('device_b'):
|
||||
self.fields['interface_b'].choices = [
|
||||
(iface.id, {'label': iface.name, 'disabled': iface.is_connected}) for iface in self.fields['interface_b'].queryset
|
||||
]
|
||||
|
||||
|
||||
class InterfaceConnectionCSVForm(forms.ModelForm):
|
||||
|
@ -43,8 +43,9 @@ $(document).ready(function() {
|
||||
real_field.empty();
|
||||
real_field.append($("<option></option>").attr('value', ui.item.value).text(ui.item.label));
|
||||
real_field.change();
|
||||
// If the field has a parent helper, reset the parent to no selection
|
||||
// Disable parent selection fields
|
||||
$('select[filter-for="' + real_field.attr('name') + '"]').val('');
|
||||
$('#select select').attr('disabled', 'disabled');
|
||||
},
|
||||
minLength: 4,
|
||||
delay: 500
|
||||
|
@ -472,6 +472,9 @@ class ChainedFieldsMixin(forms.BaseForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ChainedFieldsMixin, self).__init__(*args, **kwargs)
|
||||
|
||||
# if self.is_bound:
|
||||
# assert False, self.data
|
||||
|
||||
for field_name, field in self.fields.items():
|
||||
|
||||
if isinstance(field, ChainedModelChoiceField):
|
||||
|
Reference in New Issue
Block a user