From ebc412607ee301b6615ae91bbb8112d72c9cadc0 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 28 Oct 2010 07:26:10 +0000 Subject: Update modelfunctions and viewfunctions to allow specifying option value and label. --- lib/viewfunctions.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/viewfunctions.lua') diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua index c744802..5950af1 100644 --- a/lib/viewfunctions.lua +++ b/lib/viewfunctions.lua @@ -51,11 +51,19 @@ function displayformitem(myitem, name, viewtype, header_level, group) end local reverseopt = {} for x,val in ipairs(myitem.option) do - reverseopt[val] = x - myitem.value = val - myitem.checked = reverseval[val] + local v,l + if type(val) == "string" then + v = val + l = val + else + v = val.value + l = val.label + end + reverseopt[v] = x + myitem.value = v + myitem.checked = reverseval[v] myitem.name = tempname .. "." .. x - io.write(html.form.checkbox(myitem) .. html.html_escape(val) .. "
\n") + io.write(html.form.checkbox(myitem) .. html.html_escape(l) .. "
\n") end -- Check for values not in options if myitem.errtxt then -- cgit v1.2.3