luci-base: emit a warning if cbi() delegates a SimpleForm instance
authorJo-Philipp Wich <jo@mein.io>
Fri, 6 Apr 2018 10:07:01 +0000 (12:07 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 6 Apr 2018 10:07:49 +0000 (12:07 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/luasrc/dispatcher.lua

index 88f9440..4866727 100644 (file)
@@ -816,7 +816,16 @@ local function _cbi(self, ...)
 
        local state = nil
 
 
        local state = nil
 
+       local i, res
        for i, res in ipairs(maps) do
        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
                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 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
        for i, res in ipairs(maps) do
                local cstate = res:parse()
                if cstate and (not state or cstate < state) then