libs/cbi: Fixed MultiValues
This commit is contained in:
parent
89764da368
commit
d12dfa5186
1 changed files with 5 additions and 11 deletions
|
@ -729,21 +729,15 @@ function MultiValue.valuelist(self, section)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MultiValue.validate(self, val)
|
function MultiValue.validate(self, val)
|
||||||
if not(type(val) == "string") then
|
val = (type(val) == "table") and val or {val}
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = ""
|
local result
|
||||||
|
|
||||||
for value in val:gmatch("[^\n]+") do
|
for i, value in ipairs(val) do
|
||||||
if luci.util.contains(self.keylist, value) then
|
if luci.util.contains(self.keylist, value) then
|
||||||
result = result .. self.delimiter .. value
|
result = result and (result .. self.delimiter .. value) or value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if result:len() > 0 then
|
return result
|
||||||
return result:sub(self.delimiter:len() + 1)
|
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue