From bf71ae5f1b9eef61f61f917a5f24cbbdab418e70 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 6 Apr 2018 12:07:01 +0200 Subject: [PATCH] luci-base: emit a warning if cbi() delegates a SimpleForm instance Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/dispatcher.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua index 88f9440c5..486672757 100644 --- a/modules/luci-base/luasrc/dispatcher.lua +++ b/modules/luci-base/luasrc/dispatcher.lua @@ -816,7 +816,16 @@ local function _cbi(self, ...) local state = nil + local i, res for i, res in ipairs(maps) do + if util.instanceof(res, cbi.SimpleForm) then + io.stderr:write("Model %s returns SimpleForm but is dispatched via cbi(),\n" + % self.model) + + io.stderr:write("please change %s to use the form() action instead.\n" + % table.concat(context.request, "/")) + end + res.flow = config local cstate = res:parse() if cstate and (not state or cstate < state) then @@ -937,6 +946,7 @@ local function _form(self, ...) local maps = luci.cbi.load(self.model, ...) local state = nil + local i, res for i, res in ipairs(maps) do local cstate = res:parse() if cstate and (not state or cstate < state) then -- 2.11.0