libs/web: handle empty tables in Map.set()
[project/luci.git] / libs / web / luasrc / cbi.lua
index 6934be6..f4bf18d 100644 (file)
@@ -378,10 +378,14 @@ end
 
 -- UCI set
 function Map.set(self, section, option, value)
-       if option then
-               return self.uci:set(self.config, section, option, value)
+       if type(value) ~= "table" or #value > 0 then
+               if option then
+                       return self.uci:set(self.config, section, option, value)
+               else
+                       return self.uci:set(self.config, section, value)
+               end
        else
-               return self.uci:set(self.config, section, value)
+               return Map.del(self, section, option)
        end
 end