liquid_feedback_frontend

view app/main/registration/_register_form.lua @ 1395:dbf90b71b19e

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

Impressum / About Us