Skip to content

Commit

Permalink
luci-compat: CBI skip fields that do not satisfy depends
Browse files Browse the repository at this point in the history
If depends is not satisfied, the fvalue will be nil.

Signed-off-by: Liangbin Lian <[email protected]>
  • Loading branch information
jjm2473 committed Dec 25, 2024
1 parent 679d3b8 commit 4860e90
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/luci-compat/luasrc/cbi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1695,6 +1695,7 @@ function MultiValue.__init__(self, ...)

self.widget = "checkbox"
self.delimiter = " "
self.nilasempty = true

self:reset_values()
end
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4860e90

Please sign in to comment.