From 9a863c8888fd088988f3857e1acdc91c248e83e0 Mon Sep 17 00:00:00 2001 From: Liangbin Lian Date: Tue, 10 Dec 2024 17:39:29 +0800 Subject: [PATCH] luci-compat: CBI skip fields that do not satisfy depends If depends is not satisfied, the fvalue will be nil. Signed-off-by: Liangbin Lian --- modules/luci-compat/luasrc/cbi.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/luci-compat/luasrc/cbi.lua b/modules/luci-compat/luasrc/cbi.lua index 450e413916..5f7524be11 100644 --- a/modules/luci-compat/luasrc/cbi.lua +++ b/modules/luci-compat/luasrc/cbi.lua @@ -1456,7 +1456,7 @@ function AbstractValue.parse(self, section, novld) --luci.util.append(self.map.events, self.events) end end - elseif cvalue ~= fvalue and not novld then + elseif (fvalue ~= nil or self.nilasempty) and cvalue ~= fvalue and not novld then -- trigger validator with nil value to get custom user error msg. local _, val_err = self:validate(nil, section) self:add_error(section, "missing", val_err) @@ -1695,6 +1695,7 @@ function MultiValue.__init__(self, ...) self.widget = "checkbox" self.delimiter = " " + self.nilasempty = true self:reset_values() end @@ -1785,6 +1786,7 @@ function DynamicList.__init__(self, ...) AbstractValue.__init__(self, ...) self.template = "cbi/dynlist" self.cast = "table" + self.nilasempty = true self:reset_values() end -- 2.30.2