From a8fc4bf73eb00191e99d594b3a98535db8a83a3e Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 20 Feb 2020 16:59:24 +0000 Subject: Add optgroup support to select input --- lib/modelfunctions.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/modelfunctions.lua') diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua index b72e610..230c15c 100644 --- a/lib/modelfunctions.lua +++ b/lib/modelfunctions.lua @@ -155,8 +155,16 @@ function mymodule.validateselect(select) for i,option in ipairs(select.option) do if type(option) == "string" and option == select.value then return true - elseif type(option) == "table" and option.value == select.value then + elseif type(option.value) == "string" and option.value == select.value then return true + elseif type(option.value) == "table" then + for j,opt in ipairs(option.value) do + if type(opt) == "string" and opt == select.value then + return true + elseif type(opt.value) == "string" and opt.value == select.value then + return true + end + end end end select.errtxt = "Invalid selection" @@ -168,8 +176,16 @@ function mymodule.validatemulti(multi) for i,option in ipairs(multi.option) do if type(option) == "string" then reverseoption[option] = i - else + elseif (type(option.value) == "string") then reverseoption[option.value] = i + elseif (type(option.value) == "table") then + for j,opt in ipairs(option.value) do + if type(opt) == "string" then + reverseoption[opt] = i + elseif (type(opt.value) == "string") then + reverseoption[opt.value] = i + end + end end end for i,value in ipairs(multi.value) do -- cgit v1.2.3