liquid_feedback_frontend
view app/main/registration/_register_form.lua @ 1374:866021907392
Added whitespace after file upload label
| author | bsw |
|---|---|
| date | Wed Aug 08 17:17:05 2018 +0200 (2018-08-08) |
| parents | 18459491a4dc |
| children | f6b61b418d8a |
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 == "image" then
91 ui.tag{ tag = "label", content = field.label }
92 slot.put(" ")
93 ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } }
94 if field.optional_checkbox then
95 ui.container{ content = function()
96 ui.tag{ tag = "input", attr = {
97 type = "checkbox",
98 name = "verification_data_" .. field.name .. "_optout",
99 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
100 } }
101 slot.put(" ")
102 ui.tag{ content = field.optional_checkbox }
103 end }
104 end
106 elseif field.name == "unit" then
107 local units_selector = Unit:new_selector()
108 :add_where{ "active" }
109 if field.where then
110 units_selector:add_where(field.where)
111 end
112 local units = {}
113 if field.optional then
114 table.insert(units, {
115 id = "",
116 name = _"None"
117 })
118 end
119 for i_unit, unit in ipairs(units_selector:exec()) do
120 table.insert(units, unit)
121 end
122 ui.field.select{
123 label = field.label,
124 foreign_records = units,
125 foreign_id = "id",
126 foreign_name = "name",
127 name = "verification_data_" .. field.name,
128 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
129 }
130 else
131 if field.name == "mobile_phone" then
132 if config.self_registration.lang ~= "en" then
133 ui.tag{ content = "+39" }
134 slot.put(" ")
135 end
136 end
137 ui.field.text{
138 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
139 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
140 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
141 label = field.label,
142 name = "verification_data_" .. field.name,
143 value = request.get_param{ name = "verification_data_" .. field.name }
144 }
145 end
146 slot.put("<br />")
147 end
148 end
