libs/cbi:

- add workaround for libuci-lua bug when writing list values
	- compare values against keyllist not vallist when validating StaticList
	-> fixes StaticList and DynamicList widgets
This commit is contained in:
Jo-Philipp Wich 2009-01-20 00:05:18 +00:00
parent 06cdb07211
commit 10ab31ef5f

View file

@ -1264,6 +1264,13 @@ AbstractValue.transform = AbstractValue.validate
-- Write to UCI
function AbstractValue.write(self, section, value)
-- Work around a bug in libuci-lua;
-- list values are not overwritten but appended, resolve this
-- by removing the value before
if type(value) == "table" then
self.map:del(section, self.option)
end
return self.map:set(section, self.option, value)
end
@ -1501,7 +1508,7 @@ function StaticList.validate(self, value)
local valid = {}
for i, v in ipairs(value) do
if luci.util.contains(self.vallist, v) then
if luci.util.contains(self.keylist, v) then
table.insert(valid, v)
end
end