local stat, err = util.copcall(dispatch, context.request)
if not stat then
+ luci.util.perror(err)
error500(err)
end
--- Create a CBI model dispatching target.
-- @param model CBI model tpo be rendered
-function cbi(model)
+function cbi(model, config)
+ config = config or {}
return function(...)
require("luci.cbi")
require("luci.template")
local state = nil
for i, res in ipairs(maps) do
+ if config.autoapply then
+ res.autoapply = config.autoapply
+ end
local cstate = res:parse()
if not state or cstate < state then
state = cstate
end
http.header("X-CBI-State", state or 0)
- luci.template.render("cbi/header")
+ luci.template.render("cbi/header", {state = state})
for i, res in ipairs(maps) do
res:render()
end
- luci.template.render("cbi/footer")
+ luci.template.render("cbi/footer", {state = state, autoapply = config.autoapply})
end
end