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/modelfunctions.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/modelfunctions.lua') 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 -- cgit v1.2.3