summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-10-15 14:30:13 +0000
committerTed Trask <ttrask01@yahoo.com>2010-10-15 14:30:13 +0000
commitb6e47a6c610c259172e39f28e89f5438535578c1 (patch)
tree7c3c7b91657b8a655013d53d38e838301c7cc476 /lib
parent6298d6adc2626dd9e30f6af6f173c355a1036395 (diff)
downloadacf-core-b6e47a6c610c259172e39f28e89f5438535578c1.tar.bz2
acf-core-b6e47a6c610c259172e39f28e89f5438535578c1.tar.xz
Modifed displayform and handle_clientdata to allow cfe groups in forms, displayed under header tag.
Diffstat (limited to 'lib')
-rw-r--r--lib/controllerfunctions.lua10
-rw-r--r--lib/viewfunctions.lua32
2 files changed, 29 insertions, 13 deletions
diff --git a/lib/controllerfunctions.lua b/lib/controllerfunctions.lua
index ac2388e..22e763b 100644
--- a/lib/controllerfunctions.lua
+++ b/lib/controllerfunctions.lua
@@ -1,9 +1,11 @@
module(..., package.seeall)
-function handle_clientdata(form, clientdata)
+function handle_clientdata(form, clientdata, group)
form.errtxt = nil
- for name,value in pairs(form.value) do
+ for n,value in pairs(form.value) do
value.errtxt = nil
+ local name = n
+ if group then name = group.."."..name end
if name:find("%.") then
-- If the name has a '.' in it, haserl will interpret it as a table
local actualval = clientdata
@@ -17,7 +19,9 @@ function handle_clientdata(form, clientdata)
end
clientdata[name] = actualval
end
- if value.type == "boolean" then
+ if value.type == "group" then
+ handle_clientdata(value, clientdata, name)
+ elseif value.type == "boolean" then
value.value = (clientdata[name] ~= nil) and (clientdata[name] ~= "false")
elseif value.type == "multi" then
if clientdata[name] == nil then
diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua
index c0a9240..c744802 100644
--- a/lib/viewfunctions.lua
+++ b/lib/viewfunctions.lua
@@ -16,10 +16,11 @@ function displayitem(myitem)
io.write("</DD>\n")
end
-function displayformitem(myitem, name, viewtype)
+function displayformitem(myitem, name, viewtype, header_level, group)
if not myitem then return end
if name then myitem.name = name end
- if myitem.type ~= "hidden" then
+ if group and group ~= "" then myitem.name = group.."."..myitem.name end
+ if myitem.type ~= "hidden" and myitem.type ~= "group" then
io.write("<DT")
if myitem.errtxt then
myitem.class = "error"
@@ -31,7 +32,13 @@ function displayformitem(myitem, name, viewtype)
if (viewtype == "viewonly") then
myitem.disabled = "true"
end
- if myitem.type == "multi" then
+ if myitem.type == "group" then
+ header_level = header_level or 2
+ io.write("<H"..tostring(header_level)..">"..html.html_escape(myitem.label).."</H"..tostring(header_level)..">")
+ if myitem.descr then io.write('<P CLASS="descr">' .. string.gsub(html.html_escape(myitem.descr), "\n", "<BR>") .. "</P>\n") end
+ if myitem.errtxt then io.write('<P CLASS="error">' .. string.gsub(html.html_escape(myitem.errtxt), "\n", "<BR>") .. "</P>\n") end
+ displayformcontents(myitem, nil, nil, tonumber(header_level)+1, myitem.name)
+ elseif myitem.type == "multi" then
-- FIXME multiple select doesn't work in haserl, so use series of checkboxes
--myitem.type = "select"
--myitem.multiple = "true"
@@ -77,7 +84,7 @@ function displayformitem(myitem, name, viewtype)
else
io.write((html.form[myitem.type](myitem) or "") .. "\n")
end
- if myitem.type ~= "hidden" then
+ if myitem.type ~= "hidden" and myitem.type ~= "group" then
if myitem.descr then io.write('<P CLASS="descr">' .. string.gsub(html.html_escape(myitem.descr), "\n", "<BR>") .. "</P>\n") end
if myitem.errtxt then io.write('<P CLASS="error">' .. string.gsub(html.html_escape(myitem.errtxt), "\n", "<BR>") .. "</P>\n") end
io.write("</DD>\n")
@@ -102,9 +109,8 @@ function displayformstart(myform, page_info)
end
end
-function displayform(myform, order, finishingorder, page_info)
+function displayformcontents(myform, order, finishingorder, header_level, group)
if not myform then return end
- displayformstart(myform, page_info)
if not order and not finishingorder then
tmporder = {}
for name,item in pairs(myform.value) do
@@ -126,7 +132,7 @@ function displayform(myform, order, finishingorder, page_info)
reverseorder[name] = x
if myform.value[name] then
myform.value[name].name = name
- displayformitem(myform.value[name])
+ displayformitem(myform.value[name], nil, nil, header_level, group)
end
end
end
@@ -139,18 +145,17 @@ function displayform(myform, order, finishingorder, page_info)
for name,item in pairs(myform.value) do
if nil == reverseorder[name] and nil == reversefinishingorder[name] then
item.name = name
- displayformitem(item)
+ displayformitem(item, nil, nil, header_level, group)
end
end
if finishingorder then
for x,name in ipairs(finishingorder) do
if myform.value[name] then
myform.value[name].name = name
- displayformitem(myform.value[name])
+ displayformitem(myform.value[name], nil, nil, header_level, group)
end
end
end
- displayformend(myform)
end
function displayformend(myform)
@@ -160,6 +165,13 @@ function displayformend(myform)
io.write('</DL>\n')
end
+function displayform(myform, order, finishingorder, page_info, header_level)
+ if not myform then return end
+ displayformstart(myform, page_info)
+ displayformcontents(myform, order, finishingorder, header_level)
+ displayformend(myform)
+end
+
function displaycommandresults(commands, session, preserveerrors)
local cmdresult = {}
for i,cmd in ipairs(commands) do