mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-10 03:13:48 +02:00
#11625: Employ HTMX form rendering for device & VM interfaces
This commit is contained in:
@@ -3,6 +3,7 @@ from django.utils.translation import gettext as _
|
||||
|
||||
from dcim.choices import *
|
||||
from dcim.constants import *
|
||||
from utilities.forms.utils import get_field_value
|
||||
|
||||
__all__ = (
|
||||
'InterfaceCommonForm',
|
||||
@@ -23,6 +24,20 @@ class InterfaceCommonForm(forms.Form):
|
||||
label=_('MTU')
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Determine the selected 802.1Q mode
|
||||
interface_mode = get_field_value(self, 'mode')
|
||||
|
||||
# Delete VLAN tagging fields which are not relevant for the selected mode
|
||||
if interface_mode in (InterfaceModeChoices.MODE_ACCESS, InterfaceModeChoices.MODE_TAGGED_ALL):
|
||||
del self.fields['tagged_vlans']
|
||||
elif not interface_mode:
|
||||
del self.fields['vlan_group']
|
||||
del self.fields['untagged_vlan']
|
||||
del self.fields['tagged_vlans']
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user