summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-12-08 13:43:06 +0000
committerTed Trask <ttrask01@yahoo.com>2010-12-08 13:43:06 +0000
commit6a31c0a6e011ef8996e57a2d925510522fab56bb (patch)
tree61d0dce4986e7a6f60093c4eabf3a9cafdf5390c /lib
parent8282511fa01740b595304861f8383dc5220cc2eb (diff)
downloadacf-core-6a31c0a6e011ef8996e57a2d925510522fab56bb.tar.bz2
acf-core-6a31c0a6e011ef8996e57a2d925510522fab56bb.tar.xz
Fix viewfunctions for select/multi to display the label of the default, not the value.
Diffstat (limited to 'lib')
-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