liquid_feedback_frontend

diff app/main/survey/participate.lua @ 1743:3d61fa0d6474

Add checkboxes to survey
author bsw
date Mon Oct 11 10:47:25 2021 +0200 (2021-10-11)
parents 9f96b7e6e5f2
children f5c41bffb3ff
line diff
     1.1 --- a/app/main/survey/participate.lua	Mon Oct 11 10:39:23 2021 +0200
     1.2 +++ b/app/main/survey/participate.lua	Mon Oct 11 10:47:25 2021 +0200
     1.3 @@ -56,6 +56,7 @@
     1.4              },
     1.5              content = function()
     1.6                ui.field.hidden{ name = "question_id", value = question.id }
     1.7 +
     1.8                if question.answer_type == "radio" then
     1.9                  for i, answer_option in ipairs(question.answer_options) do
    1.10                    ui.container{ content = function()
    1.11 @@ -82,7 +83,35 @@
    1.12                        end
    1.13                      }
    1.14                    end }
    1.15 +
    1.16 +              if question.answer_type == "checkbox" then
    1.17 +                for i, answer_option in ipairs(question.answer_options) do
    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 +                        ["for"] = "answer_" .. i
    1.22 +                      },
    1.23 +                      content = function()
    1.24 +                        ui.tag{
    1.25 +                          tag = "input",
    1.26 +                          attr = {
    1.27 +                            id = "answer_" .. i,
    1.28 +                            class = "mdl-checkbox__button",
    1.29 +                            type = "checkbox",
    1.30 +                            name = "answer_" .. answer_option,
    1.31 +                            value = "1",
    1.32 +                            checked = param.get("answer_" .. answer_option) and "checked" or nil,
    1.33 +                          }
    1.34 +                        }
    1.35 +                        ui.tag{
    1.36 +                          attr = { class = "mdl-checkbox__label", ['for'] = "answer_" .. i },
    1.37 +                          content = answer_option
    1.38 +                        }
    1.39 +                      end
    1.40 +                    }
    1.41 +                  end }
    1.42                  end
    1.43 +
    1.44                  slot.put("<br>")
    1.45                  ui.tag{
    1.46                    tag = "input",

Impressum / About Us