local mymodule = {}
html = require("acf.html")
session = require("session")
local function getlabel(myitem, value)
if myitem and (myitem.type == "select" or myitem.type == "multi") then
for x,val in ipairs(myitem.option) do
local v,l
if type(val) == "string" then
v = val
l = val
else
v = val.value
l = val.label
end
if v == value then
return l
end
end
end
return tostring(value)
end
function mymodule.displayitem(myitem, header_level, page_info)
if not myitem then return end
if myitem.type == "form" then
header_level = header_level or 1
io.write("
" .. string.gsub(html.html_escape(myitem.descr), "\n", "
") .. "
" .. string.gsub(html.html_escape(myitem.errtxt), "\n", "
") .. "
" .. html.html_escape(myitem.label) .. "
") io.write("" .. string.gsub(html.html_escape(myitem.descr), "\n", "
") .. "
" .. string.gsub(html.html_escape(myitem.errtxt), "\n", "
") .. "
" .. string.gsub(html.html_escape(myitem.descr), "\n", "
") .. "
" .. string.gsub(html.html_escape(myitem.errtxt), "\n", "
") .. "
\n')
end
for x,val in ipairs(tempval) do
if not reverseopt[val] then
myitem.value = val
myitem.checked = true
io.write(html.form.checkbox(myitem) .. html.html_escape(val) .. "
\n")
end
end
if myitem.errtxt then
io.write('
" .. string.gsub(html.html_escape(myitem.descr), "\n", "
") .. "
Default:' .. string.gsub(html.html_escape(getlabel(myitem, myitem.default)), "\n", "
") .. "
" .. string.gsub(html.html_escape(myitem.errtxt), "\n", "
") .. "
' .. string.gsub(html.html_escape(myform.descr), "\n", "
") .. "
' .. string.gsub(html.html_escape(myform.errtxt), "\n", "
") .. "
' .. string.gsub(html.html_escape(result.value), "\n", "
") .. "
' .. string.gsub(html.html_escape(result.descr), "\n", "
") .. "
' .. string.gsub(html.html_escape(result.errtxt), "\n", "
") .. "
" .. html.html_escape(value) .. "" return value end end return mymodule