diff options
author | Ted Trask <ttrask01@yahoo.com> | 2012-02-23 15:27:32 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2012-02-23 15:27:32 +0000 |
commit | 94e98d227ef5e21485bafd859b23d5d709ba79a8 (patch) | |
tree | f783f44685aaa33c0c127b992f74aad965deefad /lua | |
parent | efdd93c695574329b3d98455a0a88320a1c79d5b (diff) | |
download | acf-core-94e98d227ef5e21485bafd859b23d5d709ba79a8.tar.bz2 acf-core-94e98d227ef5e21485bafd859b23d5d709ba79a8.tar.xz |
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
Diffstat (limited to 'lua')
-rwxr-xr-x | lua/mvc.lua | 31 |
1 files changed, 31 insertions, 0 deletions
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 |