liquid_feedback_frontend

view app/main/registration/_register_form.lua @ 1378:1b630b012aba

Added missing brackets
author bsw
date Wed Aug 08 17:36:12 2018 +0200 (2018-08-08)
parents 9b9c08e37435
children 4b558772a66d
line source
1 for i, field in ipairs(config.self_registration.fields) do
2 local class = ""
3 local field_error = slot.get_content("self_registration__invalid_" .. field.name)
4 if field_error == "" then
5 field_error = nil
6 end
7 if field_error then
8 class = " is-invalid"
9 end
10 if not field.internal then
11 if field.name == "date_of_birth" then
12 slot.put("<br />")
13 local label = field.label
14 if field.optional then
15 label = label .. config.self_registration.optional_field_indicator
16 end
17 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 .. ":" }
18 slot.put(" &nbsp; ")
19 local days = { { id = 0, name = _"day" } }
20 for i = 1, 31 do
21 table.insert(days, { id = i, name = i })
22 end
23 local months = {
24 { id = 0, name = _"month" },
25 { id = 1, name = "gennaio" },
26 { id = 2, name = "febbraio" },
27 { id = 3, name = "marzo" },
28 { id = 4, name = "aprile" },
29 { id = 5, name = "maggio" },
30 { id = 6, name = "giugno" },
31 { id = 7, name = "luglio" },
32 { id = 8, name = "agosto" },
33 { id = 9, name = "settembre" },
34 { id = 10, name = "ottobre" },
35 { id = 11, name = "novembre" },
36 { id = 12, name = "dicembre" },
37 }
38 if config.self_registration.lang == "en" then
39 months = {
40 { id = 0, name = _"month" },
41 { id = 1, name = "January" },
42 { id = 2, name = "February" },
43 { id = 3, name = "March" },
44 { id = 4, name = "April" },
45 { id = 5, name = "May" },
46 { id = 6, name = "June" },
47 { id = 7, name = "July" },
48 { id = 8, name = "August" },
49 { id = 9, name = "September" },
50 { id = 10, name = "October" },
51 { id = 11, name = "November" },
52 { id = 12, name = "December" },
53 }
54 end
55 local years = { { id = 0, name = _"year" } }
56 for i = 2002, 1900, -1 do
57 table.insert(years, { id = i, name = i })
58 end
59 ui.field.select{
60 container_attr = { style = "display: inline-block; " },
61 attr = { class = class },
62 foreign_records = days,
63 foreign_id = "id",
64 foreign_name = "name",
65 name = "verification_data_" .. field.name .. "_day",
66 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" })
67 }
68 slot.put(" &nbsp; ")
69 ui.field.select{
70 container_attr = { style = "display: inline-block; " },
71 attr = { class = class },
72 foreign_records = months,
73 foreign_id = "id",
74 foreign_name = "name",
75 name = "verification_data_" .. field.name .. "_month",
76 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" })
77 }
78 slot.put(" &nbsp; ")
79 ui.field.select{
80 container_attr = { style = "display: inline-block; " },
81 attr = { class = class },
82 foreign_records = years,
83 foreign_id = "id",
84 foreign_name = "name",
85 name = "verification_data_" .. field.name .. "_year",
86 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" })
87 }
88 slot.put("<br />")
90 elseif field.type == "dropdown" then
91 local options = { { id = "", value = field.label } }
92 for i_options, option in ipairs(field.options) do
93 table.insert(options, option)
94 end
95 ui.field.select{
96 container_attr = { style = "display: inline-block; " },
97 attr = { class = class },
98 foreign_records = options,
99 foreign_id = "id",
100 foreign_name = "name",
101 name = "verification_data_" .. field.name,
102 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
103 }
105 elseif field.type == "image" then
106 ui.tag{ tag = "label", content = field.label }
107 slot.put(" ")
108 ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } }
109 if field.optional_checkbox then
110 ui.tag{ tag = "label", attr = {
111 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
112 ["for"] = "verification_data_" .. field.name .. "_optout"
113 },
114 content = function()
115 ui.tag{
116 tag = "input",
117 attr = {
118 type = "checkbox",
119 class = "mdl-checkbox__input",
120 id = "verification_data_" .. field.name .. "_optout",
121 name = "verification_data_" .. field.name .. "_optout",
122 value = "1",
123 style = "float: left;",
124 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
125 }
126 }
127 ui.tag{
128 attr = { class = "mdl-checkbox__label" },
129 content = field.optional_checkbox
130 }
131 end
132 }
133 end
135 elseif field.name == "unit" then
136 local units_selector = Unit:new_selector()
137 :add_where{ "active" }
138 if field.where then
139 units_selector:add_where(field.where)
140 end
141 local units = {}
142 if field.optional then
143 table.insert(units, {
144 id = "",
145 name = _"None"
146 })
147 end
148 for i_unit, unit in ipairs(units_selector:exec()) do
149 table.insert(units, unit)
150 end
151 ui.field.select{
152 label = field.label,
153 foreign_records = units,
154 foreign_id = "id",
155 foreign_name = "name",
156 name = "verification_data_" .. field.name,
157 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
158 }
159 else
160 if field.name == "mobile_phone" then
161 if config.self_registration.lang ~= "en" then
162 ui.tag{ content = "+39" }
163 slot.put(" ")
164 end
165 end
166 ui.field.text{
167 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
168 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
169 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
170 label = field.label,
171 name = "verification_data_" .. field.name,
172 value = request.get_param{ name = "verification_data_" .. field.name }
173 }
174 end
175 slot.put("<br />")
176 end
177 end

Impressum / About Us