From bf06405854b19097e4aa1d3981f5e78727331d8c Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 22 Oct 2008 20:36:29 +0000 Subject: Modified viewfunctions displaycommandresults to not delete the error results of a form so the form can still display it. Modified a bunch of views to display the results of component forms. Also added code to displayform and displayformstart to automatically generate the action if passed page_info. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1561 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/viewfunctions.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/viewfunctions.lua') diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua index c3e4b6a..693b3d8 100644 --- a/lib/viewfunctions.lua +++ b/lib/viewfunctions.lua @@ -165,8 +165,11 @@ function displayformitem(myitem, name, viewtype) io.write("\n") end -function displayformstart(myform) +function displayformstart(myform, page_info) if not myform then return end + if not myform.action and page_info then + myform.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action + end if myform.descr then io.write('

' .. string.gsub(myform.descr, "\n", "
") .. "

\n") end if myform.errtxt then io.write('

' .. string.gsub(myform.errtxt, "\n", "
") .. "

\n") end io.write('
\n') @@ -175,9 +178,9 @@ function displayformstart(myform) end end -function displayform(myform, order, finishingorder) +function displayform(myform, order, finishingorder, page_info) if not myform then return end - displayformstart(myform) + displayformstart(myform, page_info) io.write('
\n') local reverseorder= {["redir"]=0} if order then @@ -221,12 +224,14 @@ function displayformend(myform) io.write('') end -function displaycommandresults(commands, session) +function displaycommandresults(commands, session, preserveerrors) local cmdresult = {} for i,cmd in ipairs(commands) do if session[cmd.."result"] then cmdresult[#cmdresult + 1] = session[cmd.."result"] - session[cmd.."result"] = nil + if not preserveerrors or not session[cmd.."result"].errtxt then + session[cmd.."result"] = nil + end end end if #cmdresult > 0 then -- cgit v1.2.3