liquid_feedback_frontend
view app/main/registration/_register_form.lua @ 1381:574eaf2ff457
Added white space
| author | bsw |
|---|---|
| date | Wed Aug 08 17:39:16 2018 +0200 (2018-08-08) |
| parents | 276718aedd90 |
| children | 8f4ed517bc09 |
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(" ")
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(" ")
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(" ")
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 = "", name = "" } }
92 for i_options, option in ipairs(field.options) do
93 table.insert(options, option)
94 end
95 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 .. ":" }
96 slot.put(" ")
97 ui.field.select{
98 container_attr = { style = "display: inline-block; " },
99 attr = { class = class },
100 foreign_records = options,
101 foreign_id = "id",
102 foreign_name = "name",
103 name = "verification_data_" .. field.name,
104 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
105 }
106 slot.put("<br />")
108 elseif field.type == "image" then
109 ui.tag{ tag = "label", content = field.label }
110 slot.put(" ")
111 ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } }
112 if field.optional_checkbox then
113 ui.tag{ tag = "label", attr = {
114 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
115 ["for"] = "verification_data_" .. field.name .. "_optout"
116 },
117 content = function()
118 ui.tag{
119 tag = "input",
120 attr = {
121 type = "checkbox",
122 class = "mdl-checkbox__input",
123 id = "verification_data_" .. field.name .. "_optout",
124 name = "verification_data_" .. field.name .. "_optout",
125 value = "1",
126 style = "float: left;",
127 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
128 }
129 }
130 ui.tag{
131 attr = { class = "mdl-checkbox__label" },
132 content = field.optional_checkbox
133 }
134 end
135 }
136 end
138 elseif field.name == "unit" then
139 local units_selector = Unit:new_selector()
140 :add_where{ "active" }
141 if field.where then
142 units_selector:add_where(field.where)
143 end
144 local units = {}
145 if field.optional then
146 table.insert(units, {
147 id = "",
148 name = _"None"
149 })
150 end
151 for i_unit, unit in ipairs(units_selector:exec()) do
152 table.insert(units, unit)
153 end
154 ui.field.select{
155 label = field.label,
156 foreign_records = units,
157 foreign_id = "id",
158 foreign_name = "name",
159 name = "verification_data_" .. field.name,
160 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
161 }
162 else
163 if field.name == "mobile_phone" then
164 if config.self_registration.lang ~= "en" then
165 ui.tag{ content = "+39" }
166 slot.put(" ")
167 end
168 end
169 ui.field.text{
170 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
171 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
172 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
173 label = field.label,
174 name = "verification_data_" .. field.name,
175 value = request.get_param{ name = "verification_data_" .. field.name }
176 }
177 end
178 slot.put("<br />")
179 end
180 end
