libs/cbi: Fixed CBI handling of "Save & Apply"
[project/luci.git] / modules / admin-mini / luasrc / model / cbi / mini / wifi.lua
index f612e9d..2890a78 100644 (file)
@@ -13,6 +13,7 @@ You may obtain a copy of the License at
 $Id$
 ]]--
 m = Map("wireless", translate("wifi"), translate("a_w_devices1"))
+m:chain("network")
 
 s = m:section(TypedSection, "wifi-device", translate("devices"))
 
@@ -58,15 +59,21 @@ function mode.write(self, section, value)
        if value == "sta" then
                -- ToDo: Move this away
                if not luci.model.uci.get("network", "wan") then
-                       luci.model.uci.set("network", "wan", "interface")
                        luci.model.uci.set("network", "wan", "proto", "none")
+                       luci.model.uci.set("network", "wan", "ifname", " ")
                end
 
-               luci.model.uci.set("network", "wan", "type", "bridge")
-               luci.model.uci.save("network")
+               local oldif = luci.model.uci.get("network", "wan", "ifname")
+               if oldif and oldif ~= " " then
+                       luci.model.uci.set("network", "wan", "_ifname", oldif)
+               end
+               luci.model.uci.set("network", "wan", "ifname", " ")
 
                self.map:set(section, "network", "wan")
        else
+               if luci.model.uci.get("network", "wan", "_ifname") then
+                       luci.model.uci.set("network", "wan", "ifname", luci.model.uci.get("network", "wan", "_ifname"))
+               end
                self.map:set(section, "network", "lan")
        end