diff options
author | Steven Barth <steven@midlink.org> | 2008-08-09 14:14:04 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-09 14:14:04 +0000 |
commit | bdb4bbde130ba4cfb86746dde2905fc12b94175f (patch) | |
tree | a71d55bfc51b603f2c87b8727a896027436f3fd5 /libs/web | |
parent | b71825db91b3d99417693dd004178ff926edc887 (diff) |
libs/cbi: Major Improvements
Added initial support for non-UCI-based forms (luci.cbi.SimpleForm)
Minor API improvements
Now correctly tagging "empty mandatory field" errors
Diffstat (limited to 'libs/web')
-rw-r--r-- | libs/web/luasrc/dispatcher.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 9ba74c49c..d9917c2a8 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -461,3 +461,32 @@ function cbi(model) luci.template.render("cbi/footer") end end + +--- Create a CBI form model dispatching target. +-- @param model CBI form model tpo be rendered +function form(model) + require("luci.cbi") + require("luci.template") + + return function(...) + local stat, maps = luci.util.copcall(luci.cbi.load, model, ...) + if not stat then + error500(maps) + return true + end + + for i, res in ipairs(maps) do + local stat, err = luci.util.copcall(res.parse, res) + if not stat then + error500(err) + return true + end + end + + luci.template.render("header") + for i, res in ipairs(maps) do + res:render() + end + luci.template.render("footer") + end +end |