summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-09 14:14:04 +0000
committerSteven Barth <steven@midlink.org>2008-08-09 14:14:04 +0000
commitbdb4bbde130ba4cfb86746dde2905fc12b94175f (patch)
treea71d55bfc51b603f2c87b8727a896027436f3fd5 /libs/web/luasrc
parentb71825db91b3d99417693dd004178ff926edc887 (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/luasrc')
-rw-r--r--libs/web/luasrc/dispatcher.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index 9ba74c49c9..d9917c2a87 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