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 <jjm2473@gmail.com>
This commit is contained in:
Liangbin Lian
2024-12-10 17:39:29 +08:00
committed by Paul Donald
parent d16ffa3113
commit 9a863c8888

View File

@@ -1456,7 +1456,7 @@ function AbstractValue.parse(self, section, novld)
--luci.util.append(self.map.events, self.events) --luci.util.append(self.map.events, self.events)
end end
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. -- trigger validator with nil value to get custom user error msg.
local _, val_err = self:validate(nil, section) local _, val_err = self:validate(nil, section)
self:add_error(section, "missing", val_err) self:add_error(section, "missing", val_err)
@@ -1695,6 +1695,7 @@ function MultiValue.__init__(self, ...)
self.widget = "checkbox" self.widget = "checkbox"
self.delimiter = " " self.delimiter = " "
self.nilasempty = true
self:reset_values() self:reset_values()
end end
@@ -1785,6 +1786,7 @@ function DynamicList.__init__(self, ...)
AbstractValue.__init__(self, ...) AbstractValue.__init__(self, ...)
self.template = "cbi/dynlist" self.template = "cbi/dynlist"
self.cast = "table" self.cast = "table"
self.nilasempty = true
self:reset_values() self:reset_values()
end end