summaryrefslogtreecommitdiffstats
path: root/lib/viewfunctions.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/viewfunctions.lua')
-rw-r--r--lib/viewfunctions.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua
index bcb8a2c..d7d25f8 100644
--- a/lib/viewfunctions.lua
+++ b/lib/viewfunctions.lua
@@ -1,6 +1,25 @@
require("html")
require("session")
+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 value
+end
+
function displayitem(myitem)
if not myitem then return end
io.write("<DT")
@@ -94,7 +113,7 @@ function displayformitem(myitem, name, viewtype, header_level, group)
end
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.default then io.write('<P CLASS="descr">Default:' .. string.gsub(html.html_escape(myitem.default), "\n", "<BR>") .. "</P>\n") end
+ if myitem.default then io.write('<P CLASS="descr">Default:' .. string.gsub(html.html_escape(getlabel(myitem, myitem.default)), "\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")
end