liquid_feedback_frontend

view app/main/registration/_register_form.lua @ 1400:e8e4396fd73c

Changed style of register image upload 10
author bsw
date Mon Aug 13 19:37:22 2018 +0200 (2018-08-13)
parents 20c293c7b78e
children cd9ab9f36375
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 local label = field.label
13 if field.optional then
14 label = label .. config.self_registration.optional_field_indicator
15 end
16 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 .. ":" }
17 slot.put("   ")
18 local days = { { id = 0, name = _"day" } }
19 for i = 1, 31 do
20 table.insert(days, { id = i, name = i })
21 end
22 local months = {
23 { id = 0, name = _"month" },
24 { id = 1, name = "gennaio" },
25 { id = 2, name = "febbraio" },
26 { id = 3, name = "marzo" },
27 { id = 4, name = "aprile" },
28 { id = 5, name = "maggio" },
29 { id = 6, name = "giugno" },
30 { id = 7, name = "luglio" },
31 { id = 8, name = "agosto" },
32 { id = 9, name = "settembre" },
33 { id = 10, name = "ottobre" },
34 { id = 11, name = "novembre" },
35 { id = 12, name = "dicembre" },
36 }
37 if config.self_registration.lang == "en" then
38 months = {
39 { id = 0, name = _"month" },
40 { id = 1, name = "January" },
41 { id = 2, name = "February" },
42 { id = 3, name = "March" },
43 { id = 4, name = "April" },
44 { id = 5, name = "May" },
45 { id = 6, name = "June" },
46 { id = 7, name = "July" },
47 { id = 8, name = "August" },
48 { id = 9, name = "September" },
49 { id = 10, name = "October" },
50 { id = 11, name = "November" },
51 { id = 12, name = "December" },
52 }
53 end
54 local years = { { id = 0, name = _"year" } }
55 for i = 2002, 1900, -1 do
56 table.insert(years, { id = i, name = i })
57 end
58 ui.field.select{
59 container_attr = { style = "display: inline-block; " },
60 attr = { class = class },
61 foreign_records = days,
62 foreign_id = "id",
63 foreign_name = "name",
64 name = "verification_data_" .. field.name .. "_day",
65 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" })
66 }
67 slot.put("   ")
68 ui.field.select{
69 container_attr = { style = "display: inline-block; " },
70 attr = { class = class },
71 foreign_records = months,
72 foreign_id = "id",
73 foreign_name = "name",
74 name = "verification_data_" .. field.name .. "_month",
75 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" })
76 }
77 slot.put("   ")
78 ui.field.select{
79 container_attr = { style = "display: inline-block; " },
80 attr = { class = class },
81 foreign_records = years,
82 foreign_id = "id",
83 foreign_name = "name",
84 name = "verification_data_" .. field.name .. "_year",
85 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" })
86 }
87 slot.put("<br />")
89 elseif field.type == "dropdown" then
90 local options = { { id = "", name = "" } }
91 for i_options, option in ipairs(field.options) do
92 table.insert(options, option)
93 end
94 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 .. ":" }
95 slot.put(" &nbsp; ")
96 ui.field.select{
97 container_attr = { style = "display: inline-block; " },
98 attr = { class = class },
99 foreign_records = options,
100 foreign_id = "id",
101 foreign_name = "name",
102 name = "verification_data_" .. field.name,
103 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
104 }
105 slot.put("<br />")
107 elseif field.type == "image" then
108 slot.put("<br />")
109 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 .. ":" }
110 slot.put("<br />")
111 ui.script{ script = [[
112 function getFile(){
113 document.getElementById("fileInput").click();
114 }
115 function fileChoosen(obj){
116 var file = obj.value;
117 var fileName = file.split("\\");
118 var checked = false;
119 var label = "]] .. field.upload_label .. [[";
120 if (fileName.length > 0) {
121 checked = true;
122 label = fileName[fileName.length-1];
123 }
124 document.getElementById("fileCheckbox").checked = checked;
125 document.getElementById("fileBtn").innerHTML = label;
126 event.preventDefault();
127 }
128 ]] }
129 ui.tag{ tag = "input", attr = { id = "fileInput", style = "display: none;", type = "file", name = "verification_data_" .. field.name, onchange = "fileChoosen(this);" } }
130 ui.tag{
131 attr = { id = "fileBtn", class = "mdl-checkbox__label", onclick = "getFile();" },
132 content = field.upload_label
133 }
134 if field.optional_checkbox then
135 slot.put(" &nbsp; ")
136 ui.tag{ tag = "label", attr = {
137 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
138 style = "display: inline;",
139 ["for"] = "verification_data_" .. field.name .. "_optout"
140 },
141 content = function()
142 ui.tag{
143 tag = "input",
144 attr = {
145 type = "checkbox",
146 class = "mdl-checkbox__input",
147 id = "verification_data_" .. field.name .. "_optout",
148 name = "verification_data_" .. field.name .. "_optout",
149 value = "1",
150 style = "float: left;",
151 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
152 }
153 }
154 ui.tag{
155 attr = { class = "mdl-checkbox__label" },
156 content = field.optional_checkbox
157 }
158 end
159 }
160 end
162 elseif field.name == "unit" then
163 local units_selector = Unit:new_selector()
164 :add_where{ "active" }
165 if field.where then
166 units_selector:add_where(field.where)
167 end
168 local units = {}
169 if field.optional then
170 table.insert(units, {
171 id = "",
172 name = _"None"
173 })
174 end
175 for i_unit, unit in ipairs(units_selector:exec()) do
176 table.insert(units, unit)
177 end
178 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 .. ":" }
179 slot.put(" &nbsp; ")
180 ui.field.select{
181 container_attr = { style = "display: inline-block; " },
182 foreign_records = units,
183 foreign_id = "id",
184 foreign_name = "name",
185 name = "verification_data_" .. field.name,
186 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
187 }
188 slot.put("<br />")
189 else
190 if field.name == "mobile_phone" then
191 if config.self_registration.lang ~= "en" then
192 ui.tag{ content = "+39" }
193 slot.put(" ")
194 end
195 end
196 ui.field.text{
197 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
198 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
199 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
200 label = field.label,
201 name = "verification_data_" .. field.name,
202 value = request.get_param{ name = "verification_data_" .. field.name }
203 }
204 end
205 slot.put("<br />")
206 end
207 end

Impressum / About Us