diff options
author | Ted Trask <ttrask01@yahoo.com> | 2020-02-20 16:59:24 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2020-02-20 16:59:24 +0000 |
commit | a8fc4bf73eb00191e99d594b3a98535db8a83a3e (patch) | |
tree | e160aa3a866bd5906665382b27e720e85a719e29 /lib/modelfunctions.lua | |
parent | 1ceb3e8e0092d71c8379c863bdbac187dac06939 (diff) | |
download | acf-core-a8fc4bf73eb00191e99d594b3a98535db8a83a3e.tar.bz2 acf-core-a8fc4bf73eb00191e99d594b3a98535db8a83a3e.tar.xz |
Add optgroup support to select input
Diffstat (limited to 'lib/modelfunctions.lua')
-rw-r--r-- | lib/modelfunctions.lua | 20 |
1 files changed, 18 insertions, 2 deletions
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 |