summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/model/uci.lua
diff options
context:
space:
mode:
authorKarl Palsson <karlp@remake.is>2015-09-02 11:24:29 +0000
committerKarl Palsson <karlp@remake.is>2015-09-02 15:27:55 +0000
commit879d9ff2b8f80b7c8e4adadf0702154d9ae932f4 (patch)
tree7c133cb360fd5cd60b3d94529eaa81513eef9a70 /modules/luci-base/luasrc/model/uci.lua
parentf0083abed10e8a397ebe9e62801e3b5d536ba7b6 (diff)
uci:set_list: Delete option if the list is empty
Allows lists fetched with get_list to be modified and simply passed back to set_list. Explicitly calling set_list() with an empty list is clearly requesting that there be zero list items, ie, deletion of the option altogether. Signed-off-by: Karl Palsson <karlp@remake.is>
Diffstat (limited to 'modules/luci-base/luasrc/model/uci.lua')
-rw-r--r--modules/luci-base/luasrc/model/uci.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/model/uci.lua b/modules/luci-base/luasrc/model/uci.lua
index 1659137742..e9bac6ec03 100644
--- a/modules/luci-base/luasrc/model/uci.lua
+++ b/modules/luci-base/luasrc/model/uci.lua
@@ -139,6 +139,9 @@ end
function Cursor.set_list(self, config, section, option, value)
if config and section and option then
+ if not value or #value == 0 then
+ return self:delete(config, section, option)
+ end
return self:set(
config, section, option,
( type(value) == "table" and value or { value } )