| rev |
line source |
|
bsw/jbe@1309
|
1 for i, field in ipairs(config.self_registration.fields) do
|
|
bsw/jbe@1309
|
2 local class = ""
|
|
bsw/jbe@1309
|
3 local field_error = slot.get_content("self_registration__invalid_" .. field.name)
|
|
bsw/jbe@1309
|
4 if field_error == "" then
|
|
bsw/jbe@1309
|
5 field_error = nil
|
|
bsw/jbe@1309
|
6 end
|
|
bsw/jbe@1309
|
7 if field_error then
|
|
bsw/jbe@1309
|
8 class = " is-invalid"
|
|
bsw/jbe@1309
|
9 end
|
|
bsw@1359
|
10 if not field.internal then
|
|
bsw@1359
|
11 if field.name == "date_of_birth" then
|
|
bsw@1359
|
12 slot.put("<br />")
|
|
bsw@1359
|
13 local label = field.label
|
|
bsw@1359
|
14 if field.optional then
|
|
bsw@1359
|
15 label = label .. config.self_registration.optional_field_indicator
|
|
bsw@1359
|
16 end
|
|
bsw@1359
|
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 .. ":" }
|
|
bsw@1359
|
18 slot.put(" ")
|
|
bsw@1359
|
19 local days = { { id = 0, name = _"day" } }
|
|
bsw@1359
|
20 for i = 1, 31 do
|
|
bsw@1359
|
21 table.insert(days, { id = i, name = i })
|
|
bsw@1359
|
22 end
|
|
bsw@1359
|
23 local months = {
|
|
bsw/jbe@1309
|
24 { id = 0, name = _"month" },
|
|
bsw@1359
|
25 { id = 1, name = "gennaio" },
|
|
bsw@1359
|
26 { id = 2, name = "febbraio" },
|
|
bsw@1359
|
27 { id = 3, name = "marzo" },
|
|
bsw@1359
|
28 { id = 4, name = "aprile" },
|
|
bsw@1359
|
29 { id = 5, name = "maggio" },
|
|
bsw@1359
|
30 { id = 6, name = "giugno" },
|
|
bsw@1359
|
31 { id = 7, name = "luglio" },
|
|
bsw@1359
|
32 { id = 8, name = "agosto" },
|
|
bsw@1359
|
33 { id = 9, name = "settembre" },
|
|
bsw@1359
|
34 { id = 10, name = "ottobre" },
|
|
bsw@1359
|
35 { id = 11, name = "novembre" },
|
|
bsw@1359
|
36 { id = 12, name = "dicembre" },
|
|
bsw@1359
|
37 }
|
|
bsw@1359
|
38 if config.self_registration.lang == "en" then
|
|
bsw@1359
|
39 months = {
|
|
bsw@1359
|
40 { id = 0, name = _"month" },
|
|
bsw@1359
|
41 { id = 1, name = "January" },
|
|
bsw@1359
|
42 { id = 2, name = "February" },
|
|
bsw@1359
|
43 { id = 3, name = "March" },
|
|
bsw@1359
|
44 { id = 4, name = "April" },
|
|
bsw@1359
|
45 { id = 5, name = "May" },
|
|
bsw@1359
|
46 { id = 6, name = "June" },
|
|
bsw@1359
|
47 { id = 7, name = "July" },
|
|
bsw@1359
|
48 { id = 8, name = "August" },
|
|
bsw@1359
|
49 { id = 9, name = "September" },
|
|
bsw@1359
|
50 { id = 10, name = "October" },
|
|
bsw@1359
|
51 { id = 11, name = "November" },
|
|
bsw@1359
|
52 { id = 12, name = "December" },
|
|
bsw@1359
|
53 }
|
|
bsw@1359
|
54 end
|
|
bsw@1359
|
55 local years = { { id = 0, name = _"year" } }
|
|
bsw@1359
|
56 for i = 2002, 1900, -1 do
|
|
bsw@1359
|
57 table.insert(years, { id = i, name = i })
|
|
bsw@1359
|
58 end
|
|
bsw@1359
|
59 ui.field.select{
|
|
bsw@1359
|
60 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
61 attr = { class = class },
|
|
bsw@1359
|
62 foreign_records = days,
|
|
bsw@1359
|
63 foreign_id = "id",
|
|
bsw@1359
|
64 foreign_name = "name",
|
|
bsw@1359
|
65 name = "verification_data_" .. field.name .. "_day",
|
|
bsw@1359
|
66 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" })
|
|
bsw@1359
|
67 }
|
|
bsw@1359
|
68 slot.put(" ")
|
|
bsw@1359
|
69 ui.field.select{
|
|
bsw@1359
|
70 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
71 attr = { class = class },
|
|
bsw@1359
|
72 foreign_records = months,
|
|
bsw@1359
|
73 foreign_id = "id",
|
|
bsw@1359
|
74 foreign_name = "name",
|
|
bsw@1359
|
75 name = "verification_data_" .. field.name .. "_month",
|
|
bsw@1359
|
76 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" })
|
|
bsw@1359
|
77 }
|
|
bsw@1359
|
78 slot.put(" ")
|
|
bsw@1359
|
79 ui.field.select{
|
|
bsw@1359
|
80 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
81 attr = { class = class },
|
|
bsw@1359
|
82 foreign_records = years,
|
|
bsw@1359
|
83 foreign_id = "id",
|
|
bsw@1359
|
84 foreign_name = "name",
|
|
bsw@1359
|
85 name = "verification_data_" .. field.name .. "_year",
|
|
bsw@1359
|
86 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" })
|
|
bsw@1359
|
87 }
|
|
bsw@1359
|
88 slot.put("<br />")
|
|
bsw@1359
|
89
|
|
bsw@1359
|
90 elseif field.type == "image" then
|
|
bsw@1359
|
91 ui.tag{ tag = "label", content = field.label }
|
|
bsw@1359
|
92 ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } }
|
|
bsw@1367
|
93 if field.optional_checkbox then
|
|
bsw@1367
|
94 ui.field.boolean{
|
|
bsw@1367
|
95 name = "verification_data_" .. field.name .. "_optout",
|
|
bsw@1367
|
96 value = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and true or false,
|
|
bsw@1367
|
97 label = field.optional_checkbox
|
|
bsw@1367
|
98 }
|
|
bsw@1367
|
99 end
|
|
bsw@1359
|
100
|
|
bsw@1359
|
101 elseif field.name == "unit" then
|
|
bsw@1359
|
102 local units_selector = Unit:new_selector()
|
|
bsw@1359
|
103 :add_where{ "active" }
|
|
bsw@1359
|
104 if field.where then
|
|
bsw@1359
|
105 units_selector:add_where(field.where)
|
|
bsw@1359
|
106 end
|
|
bsw@1359
|
107 local units = {}
|
|
bsw@1359
|
108 if field.optional then
|
|
bsw@1359
|
109 table.insert(units, {
|
|
bsw@1359
|
110 id = "",
|
|
bsw@1359
|
111 name = _"None"
|
|
bsw@1359
|
112 })
|
|
bsw@1359
|
113 end
|
|
bsw@1359
|
114 for i_unit, unit in ipairs(units_selector:exec()) do
|
|
bsw@1359
|
115 table.insert(units, unit)
|
|
bsw@1359
|
116 end
|
|
bsw@1359
|
117 ui.field.select{
|
|
bsw@1359
|
118 label = field.label,
|
|
bsw@1359
|
119 foreign_records = units,
|
|
bsw@1359
|
120 foreign_id = "id",
|
|
bsw@1359
|
121 foreign_name = "name",
|
|
bsw@1359
|
122 name = "verification_data_" .. field.name,
|
|
bsw@1359
|
123 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
|
|
bsw@1359
|
124 }
|
|
bsw@1359
|
125 else
|
|
bsw@1359
|
126 if field.name == "mobile_phone" then
|
|
bsw@1359
|
127 if config.self_registration.lang ~= "en" then
|
|
bsw@1359
|
128 ui.tag{ content = "+39" }
|
|
bsw@1359
|
129 slot.put(" ")
|
|
bsw@1359
|
130 end
|
|
bsw@1359
|
131 end
|
|
bsw@1359
|
132 ui.field.text{
|
|
bsw@1359
|
133 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
|
|
bsw@1359
|
134 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
|
|
bsw@1359
|
135 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
|
|
bsw@1359
|
136 label = field.label,
|
|
bsw@1359
|
137 name = "verification_data_" .. field.name,
|
|
bsw@1359
|
138 value = request.get_param{ name = "verification_data_" .. field.name }
|
|
bsw/jbe@1309
|
139 }
|
|
bsw/jbe@1309
|
140 end
|
|
bsw@1327
|
141 slot.put("<br />")
|
|
bsw/jbe@1309
|
142 end
|
|
bsw/jbe@1309
|
143 end
|