From 94e98d227ef5e21485bafd859b23d5d709ba79a8 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 23 Feb 2012 15:27:32 +0000 Subject: Removed controllerfunction.lua and moved handle_form and handle_clientdata into mvc.lua mvc.lua has generic versions of the functions, overridden in acf_www and acf_cli with customizations --- lua/mvc.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lua/mvc.lua') diff --git a/lua/mvc.lua b/lua/mvc.lua index c53d576..ca48be6 100755 --- a/lua/mvc.lua +++ b/lua/mvc.lua @@ -430,3 +430,34 @@ _G.cfe = cfe logevent = function ( ... ) os.execute ( "logger \"ACF: " .. (... or "") .. "\"" ) end + +handle_clientdata = function(form, clientdata) + form.errtxt = nil + for name,value in pairs(form.value) do + value.errtxt = nil + if value.type == "group" then + handle_clientdata(value, clientdata[name]) + else + value.value = clientdata[name] or value.value + end + end +end + +handle_form = function(self, getFunction, setFunction, clientdata, option, label, descr) + local form = getFunction(clientdata) + + if clientdata.submit then + self.handle_clientdata(form, clientdata) + + form = setFunction(form, clientdata.submit) + if not form.errtxt and descr then + form.descr = descr + end + end + + form.type = "form" + form.option = option or form.option + form.label = label or form.label + + return form +end -- cgit v1.2.3