summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/cbi.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-04-01 16:09:41 +0200
committerJo-Philipp Wich <jo@mein.io>2019-07-07 15:36:24 +0200
commit9c7eb1decd82344e22a10e6f5ac36b463d2149f5 (patch)
treea79b11f65288a7bc5d1c7a32a5f95ea57a1e57a3 /modules/luci-base/luasrc/cbi.lua
parent808b9f36eb60cf4717cbf28b163d7ad2faa7f157 (diff)
luci-base: switch from server side to client side widget markup
Do not render standard widgets like checkboxes, select boxes, text input fields etc. on the server side anymore but utilize the ui.js primitives instead. This avoids logic duplication between server side cbi templates and JS widgets in the future. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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 971830fe81..450e413916 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