summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/cbi.lua
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/luasrc/cbi.lua')
-rw-r--r--modules/luci-base/luasrc/cbi.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/cbi.lua b/modules/luci-base/luasrc/cbi.lua
index 971830fe8..450e41391 100644
--- a/modules/luci-base/luasrc/cbi.lua
+++ b/modules/luci-base/luasrc/cbi.lua
@@ -1347,6 +1347,18 @@ function AbstractValue.deplist2json(self, section, deplist)
return util.serialize_json(deps)
end
+-- Serialize choices
+function AbstractValue.choices(self)
+ if type(self.keylist) == "table" and #self.keylist > 0 then
+ local i, k, v = nil, nil, {}
+ for i, k in ipairs(self.keylist) do
+ v[k] = self.vallist[i] or k
+ end
+ return v
+ end
+ return nil
+end
+
-- Generates the unique CBID
function AbstractValue.cbid(self, section)
return "cbid."..self.map.config.."."..section.."."..self.option