diff --git a/plinth/modules/networks/forms.py b/plinth/modules/networks/forms.py index 784a5b5e7..86c085ff1 100644 --- a/plinth/modules/networks/forms.py +++ b/plinth/modules/networks/forms.py @@ -231,14 +231,6 @@ class PPPoEForm(EthernetForm): class WifiForm(ConnectionForm): """Form to create/edit a Wi-Fi connection.""" - field_order = [ - 'name', 'interface', 'zone', 'ssid', 'mode', 'band', 'channel', - 'bssid', 'auth_mode', 'passphrase', 'ipv4_method', 'ipv4_address', - 'ipv4_netmask', 'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns', - 'ipv6_method', 'ipv6_address', 'ipv6_prefix', 'ipv6_gateway', - 'ipv6_dns', 'ipv6_second_dns' - ] - ssid = forms.CharField(label=_('SSID'), help_text=_('The visible name of the network.')) mode = forms.ChoiceField( diff --git a/plinth/modules/networks/static/networks.js b/plinth/modules/networks/static/networks.js index a4b1d36af..14e7e1800 100644 --- a/plinth/modules/networks/static/networks.js +++ b/plinth/modules/networks/static/networks.js @@ -98,3 +98,23 @@ jQuery(function($) { }); }); + +// When there are validation errors on form elements, expand their parent +// collapsible so that the form element can be highlighted and an error tooltip +// can be show by the browser. +document.addEventListener('DOMContentLoaded', event => { + const selector = '.form-connection-edit input, .form-connection-create input'; + const input_elements = document.querySelectorAll(selector); + input_elements.forEach(input => + input.addEventListener('invalid', on_invalid_event) + ); +}); + +function on_invalid_event(event) { + const element = event.target; + console.log('Invalid event on element', element); + const parent = element.closest('.collapse'); + console.log('Invalid event with parent', parent); + // Don't use .collapse(). Instead, expand all the sections with errors. + parent.classList.add('show'); +} diff --git a/plinth/modules/networks/templates/connections_create.html b/plinth/modules/networks/templates/connections_create.html index 84d7b81be..d444340ad 100644 --- a/plinth/modules/networks/templates/connections_create.html +++ b/plinth/modules/networks/templates/connections_create.html @@ -3,7 +3,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later {% endcomment %} -{% load bootstrap %} {% load i18n %} {% block content %} @@ -13,7 +12,7 @@