luci-app-travelmate: made "ignore bssid" flag conditional
[project/luci.git] / applications / luci-app-travelmate / luasrc / model / cbi / travelmate / wifi_add.lua
index 93e8a05..e9e1ee4 100644 (file)
@@ -4,7 +4,7 @@
 local fs       = require("nixio.fs")
 local uci      = require("luci.model.uci").cursor()
 local http     = require("luci.http")
-local trmiface = uci.get("travelmate", "global", "trm_iface") or "trm_wwan"
+local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan"
 local encr_psk = {"psk", "psk2", "psk-mixed"}
 local encr_wpa = {"wpa", "wpa2", "wpa-mixed"}
 
@@ -26,16 +26,20 @@ m.hidden = {
        wpa_version = http.formvalue("wpa_version")
 }
 
-if m.hidden.ssid ~= "" then
+if m.hidden.ssid == "" then
+       wssid = m:field(Value, "ssid", translate("SSID (hidden)"))
+else
        wssid = m:field(Value, "ssid", translate("SSID"))
        wssid.datatype = "rangelength(1,32)"
        wssid.default = m.hidden.ssid or ""
-else
-       wssid = m:field(Value, "ssid", translate("SSID (hidden)"))
 end
 
 nobssid = m:field(Flag, "no_bssid", translate("Ignore BSSID"))
-nobssid.default = nobssid.enabled
+if m.hidden.ssid == "" then
+       nobssid.default = nobssid.disabled
+else
+       nobssid.default = nobssid.enabled
+end
 
 bssid = m:field(Value, "bssid", translate("BSSID"))
 bssid:depends("no_bssid", 0)