liquid_feedback_frontend

view app/main/registration/_register_form.lua @ 1396:a48d33b22384

Changed style of register image upload 6
author bsw
date Mon Aug 13 19:31:06 2018 +0200 (2018-08-13)
parents dbf90b71b19e
children 5890051ce163
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 document.getElementById("fileBtn").innerHTML = fileName[fileName.length-1];
119 document.getElementById("fileCheckbox").checked = fileName.length > 0 ? true : false;
120 event.preventDefault();
121 }
122 ]] }
123 ui.tag{ tag = "input", attr = { id = "fileInput", style = "display: none;", type = "file", name = "verification_data_" .. field.name, onchange = "fileChoosen(this);" } }
124 ui.tag{ tag = "label", attr = {
125 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
126 style = "display: inline;",
127 },
128 content = function()
129 ui.tag{
130 tag = "input",
131 attr = {
132 type = "checkbox",
133 class = "mdl-checkbox__input",
134 id = "fileCheckbox",
135 style = "float: left;",
136 onclick = "getFile();"
137 }
138 }
139 ui.tag{
140 attr = { id = "fileBtn", class = "mdl-checkbox__label", onclick = "getFile();" },
141 content = field.upload_label
142 }
143 }
144 }
145 if field.optional_checkbox then
146 slot.put(" &nbsp; ")
147 ui.tag{ tag = "label", attr = {
148 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
149 style = "display: inline;",
150 ["for"] = "verification_data_" .. field.name .. "_optout"
151 },
152 content = function()
153 ui.tag{
154 tag = "input",
155 attr = {
156 type = "checkbox",
157 class = "mdl-checkbox__input",
158 id = "verification_data_" .. field.name .. "_optout",
159 name = "verification_data_" .. field.name .. "_optout",
160 value = "1",
161 style = "float: left;",
162 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
163 }
164 }
165 ui.tag{
166 attr = { class = "mdl-checkbox__label" },
167 content = field.optional_checkbox
168 }
169 end
170 }
171 end
173 elseif field.name == "unit" then
174 local units_selector = Unit:new_selector()
175 :add_where{ "active" }
176 if field.where then
177 units_selector:add_where(field.where)
178 end
179 local units = {}
180 if field.optional then
181 table.insert(units, {
182 id = "",
183 name = _"None"
184 })
185 end
186 for i_unit, unit in ipairs(units_selector:exec()) do
187 table.insert(units, unit)
188 end
189 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 .. ":" }
190 slot.put(" &nbsp; ")
191 ui.field.select{
192 container_attr = { style = "display: inline-block; " },
193 foreign_records = units,
194 foreign_id = "id",
195 foreign_name = "name",
196 name = "verification_data_" .. field.name,
197 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
198 }
199 slot.put("<br />")
200 else
201 if field.name == "mobile_phone" then
202 if config.self_registration.lang ~= "en" then
203 ui.tag{ content = "+39" }
204 slot.put(" ")
205 end
206 end
207 ui.field.text{
208 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
209 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
210 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
211 label = field.label,
212 name = "verification_data_" .. field.name,
213 value = request.get_param{ name = "verification_data_" .. field.name }
214 }
215 end
216 slot.put("<br />")
217 end
218 end

Impressum / About Us