diff options
author | Ted Trask <ttrask01@yahoo.com> | 2010-10-28 07:26:10 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2010-10-28 07:26:10 +0000 |
commit | ebc412607ee301b6615ae91bbb8112d72c9cadc0 (patch) | |
tree | bbde274c9b9c4dadea8d3dffc46b2847956e9c81 /lib | |
parent | b6e47a6c610c259172e39f28e89f5438535578c1 (diff) | |
download | acf-core-ebc412607ee301b6615ae91bbb8112d72c9cadc0.tar.bz2 acf-core-ebc412607ee301b6615ae91bbb8112d72c9cadc0.tar.xz |
Update modelfunctions and viewfunctions to allow specifying option value and label.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/modelfunctions.lua | 10 | ||||
-rw-r--r-- | lib/viewfunctions.lua | 16 |
2 files changed, 20 insertions, 6 deletions
diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua index 3a02bd5..0004676 100644 --- a/lib/modelfunctions.lua +++ b/lib/modelfunctions.lua @@ -134,7 +134,9 @@ end function validateselect(select) for i,option in ipairs(select.option) do - if option == select.value then + if type(option) == "string" and option == select.value then + return true + elseif type(option) == "table" and option.value == select.value then return true end end @@ -145,7 +147,11 @@ end function validatemulti(multi) local reverseoption = {} for i,option in ipairs(multi.option) do - reverseoption[option] = i + if type(option) == "string" then + reverseoption[option] = i + else + reverseoption[option.value] = i + end end for i,value in ipairs(multi.value) do if not reverseoption[value] then 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) .. "<br>\n") + io.write(html.form.checkbox(myitem) .. html.html_escape(l) .. "<br>\n") end -- Check for values not in options if myitem.errtxt then |