liquid_feedback_frontend

diff app/main/registration/_register_form.lua @ 1685:d09c3a0d17e6

Added multiselect field
author bsw
date Mon Sep 20 13:03:37 2021 +0200 (2021-09-20)
parents b1cec2dcc035
children e5756a575dde
line diff
     1.1 --- a/app/main/registration/_register_form.lua	Mon Sep 20 12:32:40 2021 +0200
     1.2 +++ b/app/main/registration/_register_form.lua	Mon Sep 20 13:03:37 2021 +0200
     1.3 @@ -154,6 +154,58 @@
     1.4        end
     1.5        slot.put("<br />")
     1.6  
     1.7 +    elseif field.type == "multiselect" then
     1.8 +      local options = { { id = "", name = "" } }
     1.9 +      local other_option_id
    1.10 +      for i_options, option in ipairs(field.options) do
    1.11 +        if not option.id then
    1.12 +          option.id = option.name
    1.13 +        end
    1.14 +        local onchange_script
    1.15 +        if option.other then
    1.16 +          onchange_script = "var el = document.getElementById('lf-register__data_other_container_" .. field.name .. "'); if (this.checked) { console.log(el); el.classList.remove('hidden'); } else { el.classList.add('hidden'); };"
    1.17 +        end
    1.18 +        ui.container{ content = function()
    1.19 +          ui.tag{ tag = "label", attr = {
    1.20 +              class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
    1.21 +              style = "display: inline;",
    1.22 +              ["for"] = "verification_data_" .. field.name .. "__" .. option.id,
    1.23 +            },
    1.24 +            content = function()
    1.25 +              ui.tag{
    1.26 +                tag = "input",
    1.27 +                attr = {
    1.28 +                  type = "checkbox",
    1.29 +                  class = "mdl-checkbox__input",
    1.30 +                  onchange = onchange_script,
    1.31 +                  id = "verification_data_" .. field.name .. "__" .. option.id,
    1.32 +                  name = "verification_data_" .. field.name .. "__" .. option.id,
    1.33 +                  value = "1",
    1.34 +                  style = "float: left;",
    1.35 +                  checked = request.get_param{ name = "verification_data_" .. field.name .. "__" .. option.id } and "checked" or nil,
    1.36 +                }
    1.37 +              }
    1.38 +              ui.tag{
    1.39 +                attr = { class = "mdl-checkbox__label" },
    1.40 +                content = option.name
    1.41 +              }
    1.42 +            end
    1.43 +          }
    1.44 +        end }
    1.45 +        if option.other then
    1.46 +          slot.put(" ")
    1.47 +          ui.field.text{
    1.48 +            container_attr = { id = "lf-register__data_other_container_" .. field.name, class = "hidden mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
    1.49 +            attr = { id = "lf-register__data_other_" .. field.name, class = "mdl-textfield__input" },
    1.50 +            name = "verification_data_" .. field.name .. "_other",
    1.51 +          label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
    1.52 +            label = field.name,
    1.53 +            value = request.get_param{ name = "verification_data_" .. field.name .. "_other" }
    1.54 +          }
    1.55 +        end
    1.56 +      end
    1.57 +      slot.put("<br />")
    1.58 +
    1.59      elseif field.type == "image" then
    1.60        slot.put("<br />")
    1.61        ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }

Impressum / About Us