liquid_feedback_frontend
diff app/main/registration/_register_form.lua @ 1359:7532831a7618
Allow internal registration fields
| author | bsw |
|---|---|
| date | Mon Aug 06 13:56:43 2018 +0200 (2018-08-06) |
| parents | a1a2f59e083e |
| children | 5656b86cd2cf |
line diff
1.1 --- a/app/main/registration/_register_form.lua Mon Aug 06 13:42:37 2018 +0200 1.2 +++ b/app/main/registration/_register_form.lua Mon Aug 06 13:56:43 2018 +0200 1.3 @@ -7,128 +7,130 @@ 1.4 if field_error then 1.5 class = " is-invalid" 1.6 end 1.7 - if field.name == "date_of_birth" then 1.8 - slot.put("<br />") 1.9 - local label = field.label 1.10 - if field.optional then 1.11 - label = label .. config.self_registration.optional_field_indicator 1.12 - end 1.13 - 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 .. ":" } 1.14 - slot.put(" ") 1.15 - local days = { { id = 0, name = _"day" } } 1.16 - for i = 1, 31 do 1.17 - table.insert(days, { id = i, name = i }) 1.18 - end 1.19 - local months = { 1.20 - { id = 0, name = _"month" }, 1.21 - { id = 1, name = "gennaio" }, 1.22 - { id = 2, name = "febbraio" }, 1.23 - { id = 3, name = "marzo" }, 1.24 - { id = 4, name = "aprile" }, 1.25 - { id = 5, name = "maggio" }, 1.26 - { id = 6, name = "giugno" }, 1.27 - { id = 7, name = "luglio" }, 1.28 - { id = 8, name = "agosto" }, 1.29 - { id = 9, name = "settembre" }, 1.30 - { id = 10, name = "ottobre" }, 1.31 - { id = 11, name = "novembre" }, 1.32 - { id = 12, name = "dicembre" }, 1.33 - } 1.34 - if config.self_registration.lang == "en" then 1.35 - months = { 1.36 + if not field.internal then 1.37 + if field.name == "date_of_birth" then 1.38 + slot.put("<br />") 1.39 + local label = field.label 1.40 + if field.optional then 1.41 + label = label .. config.self_registration.optional_field_indicator 1.42 + end 1.43 + 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 .. ":" } 1.44 + slot.put(" ") 1.45 + local days = { { id = 0, name = _"day" } } 1.46 + for i = 1, 31 do 1.47 + table.insert(days, { id = i, name = i }) 1.48 + end 1.49 + local months = { 1.50 { id = 0, name = _"month" }, 1.51 - { id = 1, name = "January" }, 1.52 - { id = 2, name = "February" }, 1.53 - { id = 3, name = "March" }, 1.54 - { id = 4, name = "April" }, 1.55 - { id = 5, name = "May" }, 1.56 - { id = 6, name = "June" }, 1.57 - { id = 7, name = "July" }, 1.58 - { id = 8, name = "August" }, 1.59 - { id = 9, name = "September" }, 1.60 - { id = 10, name = "October" }, 1.61 - { id = 11, name = "November" }, 1.62 - { id = 12, name = "December" }, 1.63 + { id = 1, name = "gennaio" }, 1.64 + { id = 2, name = "febbraio" }, 1.65 + { id = 3, name = "marzo" }, 1.66 + { id = 4, name = "aprile" }, 1.67 + { id = 5, name = "maggio" }, 1.68 + { id = 6, name = "giugno" }, 1.69 + { id = 7, name = "luglio" }, 1.70 + { id = 8, name = "agosto" }, 1.71 + { id = 9, name = "settembre" }, 1.72 + { id = 10, name = "ottobre" }, 1.73 + { id = 11, name = "novembre" }, 1.74 + { id = 12, name = "dicembre" }, 1.75 + } 1.76 + if config.self_registration.lang == "en" then 1.77 + months = { 1.78 + { id = 0, name = _"month" }, 1.79 + { id = 1, name = "January" }, 1.80 + { id = 2, name = "February" }, 1.81 + { id = 3, name = "March" }, 1.82 + { id = 4, name = "April" }, 1.83 + { id = 5, name = "May" }, 1.84 + { id = 6, name = "June" }, 1.85 + { id = 7, name = "July" }, 1.86 + { id = 8, name = "August" }, 1.87 + { id = 9, name = "September" }, 1.88 + { id = 10, name = "October" }, 1.89 + { id = 11, name = "November" }, 1.90 + { id = 12, name = "December" }, 1.91 + } 1.92 + end 1.93 + local years = { { id = 0, name = _"year" } } 1.94 + for i = 2002, 1900, -1 do 1.95 + table.insert(years, { id = i, name = i }) 1.96 + end 1.97 + ui.field.select{ 1.98 + container_attr = { style = "display: inline-block; " }, 1.99 + attr = { class = class }, 1.100 + foreign_records = days, 1.101 + foreign_id = "id", 1.102 + foreign_name = "name", 1.103 + name = "verification_data_" .. field.name .. "_day", 1.104 + value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" }) 1.105 + } 1.106 + slot.put(" ") 1.107 + ui.field.select{ 1.108 + container_attr = { style = "display: inline-block; " }, 1.109 + attr = { class = class }, 1.110 + foreign_records = months, 1.111 + foreign_id = "id", 1.112 + foreign_name = "name", 1.113 + name = "verification_data_" .. field.name .. "_month", 1.114 + value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" }) 1.115 + } 1.116 + slot.put(" ") 1.117 + ui.field.select{ 1.118 + container_attr = { style = "display: inline-block; " }, 1.119 + attr = { class = class }, 1.120 + foreign_records = years, 1.121 + foreign_id = "id", 1.122 + foreign_name = "name", 1.123 + name = "verification_data_" .. field.name .. "_year", 1.124 + value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" }) 1.125 + } 1.126 + slot.put("<br />") 1.127 + 1.128 + elseif field.type == "image" then 1.129 + ui.tag{ tag = "label", content = field.label } 1.130 + ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } } 1.131 + 1.132 + elseif field.name == "unit" then 1.133 + local units_selector = Unit:new_selector() 1.134 + :add_where{ "active" } 1.135 + if field.where then 1.136 + units_selector:add_where(field.where) 1.137 + end 1.138 + local units = {} 1.139 + if field.optional then 1.140 + table.insert(units, { 1.141 + id = "", 1.142 + name = _"None" 1.143 + }) 1.144 + end 1.145 + for i_unit, unit in ipairs(units_selector:exec()) do 1.146 + table.insert(units, unit) 1.147 + end 1.148 + ui.field.select{ 1.149 + label = field.label, 1.150 + foreign_records = units, 1.151 + foreign_id = "id", 1.152 + foreign_name = "name", 1.153 + name = "verification_data_" .. field.name, 1.154 + value = tonumber(request.get_param{ name = "verification_data_" .. field.name }) 1.155 + } 1.156 + else 1.157 + if field.name == "mobile_phone" then 1.158 + if config.self_registration.lang ~= "en" then 1.159 + ui.tag{ content = "+39" } 1.160 + slot.put(" ") 1.161 + end 1.162 + end 1.163 + ui.field.text{ 1.164 + container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class }, 1.165 + attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" }, 1.166 + label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name }, 1.167 + label = field.label, 1.168 + name = "verification_data_" .. field.name, 1.169 + value = request.get_param{ name = "verification_data_" .. field.name } 1.170 } 1.171 end 1.172 - local years = { { id = 0, name = _"year" } } 1.173 - for i = 2002, 1900, -1 do 1.174 - table.insert(years, { id = i, name = i }) 1.175 - end 1.176 - ui.field.select{ 1.177 - container_attr = { style = "display: inline-block; " }, 1.178 - attr = { class = class }, 1.179 - foreign_records = days, 1.180 - foreign_id = "id", 1.181 - foreign_name = "name", 1.182 - name = "verification_data_" .. field.name .. "_day", 1.183 - value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" }) 1.184 - } 1.185 - slot.put(" ") 1.186 - ui.field.select{ 1.187 - container_attr = { style = "display: inline-block; " }, 1.188 - attr = { class = class }, 1.189 - foreign_records = months, 1.190 - foreign_id = "id", 1.191 - foreign_name = "name", 1.192 - name = "verification_data_" .. field.name .. "_month", 1.193 - value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" }) 1.194 - } 1.195 - slot.put(" ") 1.196 - ui.field.select{ 1.197 - container_attr = { style = "display: inline-block; " }, 1.198 - attr = { class = class }, 1.199 - foreign_records = years, 1.200 - foreign_id = "id", 1.201 - foreign_name = "name", 1.202 - name = "verification_data_" .. field.name .. "_year", 1.203 - value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" }) 1.204 - } 1.205 slot.put("<br />") 1.206 - 1.207 - elseif field.type == "image" then 1.208 - ui.tag{ tag = "label", content = field.label } 1.209 - ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } } 1.210 - 1.211 - elseif field.name == "unit" then 1.212 - local units_selector = Unit:new_selector() 1.213 - :add_where{ "active" } 1.214 - if field.where then 1.215 - units_selector:add_where(field.where) 1.216 - end 1.217 - local units = {} 1.218 - if field.optional then 1.219 - table.insert(units, { 1.220 - id = "", 1.221 - name = _"None" 1.222 - }) 1.223 - end 1.224 - for i_unit, unit in ipairs(units_selector:exec()) do 1.225 - table.insert(units, unit) 1.226 - end 1.227 - ui.field.select{ 1.228 - label = field.label, 1.229 - foreign_records = units, 1.230 - foreign_id = "id", 1.231 - foreign_name = "name", 1.232 - name = "verification_data_" .. field.name, 1.233 - value = tonumber(request.get_param{ name = "verification_data_" .. field.name }) 1.234 - } 1.235 - else 1.236 - if field.name == "mobile_phone" then 1.237 - if config.self_registration.lang ~= "en" then 1.238 - ui.tag{ content = "+39" } 1.239 - slot.put(" ") 1.240 - end 1.241 - end 1.242 - ui.field.text{ 1.243 - container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class }, 1.244 - attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" }, 1.245 - label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name }, 1.246 - label = field.label, 1.247 - name = "verification_data_" .. field.name, 1.248 - value = request.get_param{ name = "verification_data_" .. field.name } 1.249 - } 1.250 end 1.251 - slot.put("<br />") 1.252 end