bsw/jbe@1309: for i, field in ipairs(config.self_registration.fields) do bsw/jbe@1309: local class = "" bsw/jbe@1309: local field_error = slot.get_content("self_registration__invalid_" .. field.name) bsw/jbe@1309: if field_error == "" then bsw/jbe@1309: field_error = nil bsw/jbe@1309: end bsw/jbe@1309: if field_error then bsw/jbe@1309: class = " is-invalid" bsw/jbe@1309: end bsw@1359: if not field.internal then bsw@1359: if field.name == "date_of_birth" then bsw@1359: slot.put("
") bsw@1359: local label = field.label bsw@1359: if field.optional then bsw@1359: label = label .. config.self_registration.optional_field_indicator bsw@1359: end bsw@1359: 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: slot.put("   ") bsw@1359: local days = { { id = 0, name = _"day" } } bsw@1359: for i = 1, 31 do bsw@1359: table.insert(days, { id = i, name = i }) bsw@1359: end bsw@1359: local months = { bsw/jbe@1309: { id = 0, name = _"month" }, bsw@1359: { id = 1, name = "gennaio" }, bsw@1359: { id = 2, name = "febbraio" }, bsw@1359: { id = 3, name = "marzo" }, bsw@1359: { id = 4, name = "aprile" }, bsw@1359: { id = 5, name = "maggio" }, bsw@1359: { id = 6, name = "giugno" }, bsw@1359: { id = 7, name = "luglio" }, bsw@1359: { id = 8, name = "agosto" }, bsw@1359: { id = 9, name = "settembre" }, bsw@1359: { id = 10, name = "ottobre" }, bsw@1359: { id = 11, name = "novembre" }, bsw@1359: { id = 12, name = "dicembre" }, bsw@1359: } bsw@1359: if config.self_registration.lang == "en" then bsw@1359: months = { bsw@1359: { id = 0, name = _"month" }, bsw@1359: { id = 1, name = "January" }, bsw@1359: { id = 2, name = "February" }, bsw@1359: { id = 3, name = "March" }, bsw@1359: { id = 4, name = "April" }, bsw@1359: { id = 5, name = "May" }, bsw@1359: { id = 6, name = "June" }, bsw@1359: { id = 7, name = "July" }, bsw@1359: { id = 8, name = "August" }, bsw@1359: { id = 9, name = "September" }, bsw@1359: { id = 10, name = "October" }, bsw@1359: { id = 11, name = "November" }, bsw@1359: { id = 12, name = "December" }, bsw@1359: } bsw@1359: end bsw@1359: local years = { { id = 0, name = _"year" } } bsw@1359: for i = 2002, 1900, -1 do bsw@1359: table.insert(years, { id = i, name = i }) bsw@1359: end bsw@1359: ui.field.select{ bsw@1359: container_attr = { style = "display: inline-block; " }, bsw@1359: attr = { class = class }, bsw@1359: foreign_records = days, bsw@1359: foreign_id = "id", bsw@1359: foreign_name = "name", bsw@1359: name = "verification_data_" .. field.name .. "_day", bsw@1359: value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" }) bsw@1359: } bsw@1359: slot.put("   ") bsw@1359: ui.field.select{ bsw@1359: container_attr = { style = "display: inline-block; " }, bsw@1359: attr = { class = class }, bsw@1359: foreign_records = months, bsw@1359: foreign_id = "id", bsw@1359: foreign_name = "name", bsw@1359: name = "verification_data_" .. field.name .. "_month", bsw@1359: value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" }) bsw@1359: } bsw@1359: slot.put("   ") bsw@1359: ui.field.select{ bsw@1359: container_attr = { style = "display: inline-block; " }, bsw@1359: attr = { class = class }, bsw@1359: foreign_records = years, bsw@1359: foreign_id = "id", bsw@1359: foreign_name = "name", bsw@1359: name = "verification_data_" .. field.name .. "_year", bsw@1359: value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" }) bsw@1359: } bsw@1359: slot.put("
") bsw@1359: bsw@1359: elseif field.type == "image" then bsw@1359: ui.tag{ tag = "label", content = field.label } bsw@1374: slot.put(" ") bsw@1359: ui.tag{ tag = "input", attr = { type = "file", name = "verification_data_" .. field.name } } bsw@1367: if field.optional_checkbox then bsw@1373: ui.container{ content = function() bsw@1373: ui.tag{ tag = "input", attr = { bsw@1373: type = "checkbox", bsw@1373: name = "verification_data_" .. field.name .. "_optout", bsw@1373: checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil, bsw@1373: } } bsw@1373: slot.put(" ") bsw@1373: ui.tag{ content = field.optional_checkbox } bsw@1373: end } bsw@1367: end bsw@1359: bsw@1359: elseif field.name == "unit" then bsw@1359: local units_selector = Unit:new_selector() bsw@1359: :add_where{ "active" } bsw@1359: if field.where then bsw@1359: units_selector:add_where(field.where) bsw@1359: end bsw@1359: local units = {} bsw@1359: if field.optional then bsw@1359: table.insert(units, { bsw@1359: id = "", bsw@1359: name = _"None" bsw@1359: }) bsw@1359: end bsw@1359: for i_unit, unit in ipairs(units_selector:exec()) do bsw@1359: table.insert(units, unit) bsw@1359: end bsw@1359: ui.field.select{ bsw@1359: label = field.label, bsw@1359: foreign_records = units, bsw@1359: foreign_id = "id", bsw@1359: foreign_name = "name", bsw@1359: name = "verification_data_" .. field.name, bsw@1359: value = tonumber(request.get_param{ name = "verification_data_" .. field.name }) bsw@1359: } bsw@1359: else bsw@1359: if field.name == "mobile_phone" then bsw@1359: if config.self_registration.lang ~= "en" then bsw@1359: ui.tag{ content = "+39" } bsw@1359: slot.put(" ") bsw@1359: end bsw@1359: end bsw@1359: ui.field.text{ bsw@1359: container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class }, bsw@1359: attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" }, bsw@1359: label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name }, bsw@1359: label = field.label, bsw@1359: name = "verification_data_" .. field.name, bsw@1359: value = request.get_param{ name = "verification_data_" .. field.name } bsw/jbe@1309: } bsw/jbe@1309: end bsw@1327: slot.put("
") bsw/jbe@1309: end bsw/jbe@1309: end