How to modify cbi variable in luci before commit?

I think you need to iterate using ipairs() and make sure that it is a table to begin with... something like the code below:

list.write = function(self, section, value)
    local list
    if type(value) == "table" then
        list = value
    elseif value ~= nil then
        list = { value }
    else
        return -- should not happen, .remove() should have been called then
    end
    for _, item in ipairs(list) do
        list[_] = strip_spaces(item)
    end
    return Value.write(self, section, list)
end
1 Like