webmcp
view framework/env/ui_deprecated/select.lua @ 2:72860d232f32
Version 1.0.2
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
Fixed bug with explicit garbage collection (requests > 256kB caused an error)
Views prefixed with an underscore can't be called externally
ui.paginate now displays the last page, if the selected page number is too high.
| author | jbe/bsw |
|---|---|
| date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
| parents | 9fdfb27f8e67 |
| children |
line source
1 function ui_deprecated.select(args)
2 local record = assert(slot.get_state_table(), "ui_deprecated.select was not called within a form.").form_record
3 local value = param.get(args.field) or record[args.field]
4 local html_options = args.html_options or {}
5 html_options.name = args.field
7 ui_deprecated.tag("div", { html_options = { class="ui_field ui_select" }, content = function()
8 if args.label then
9 ui_deprecated.tag("div", { html_options = { class="label" }, content = function()
10 ui_deprecated.text(args.label)
11 end })
12 end
13 ui_deprecated.tag("div", { html_options = { class="value" }, content = function()
14 ui_deprecated.tag("select", { html_options = html_options, content = function()
15 if args.include_option then
16 ui_deprecated.tag("option", { html_options = { value = "" }, content = args.include_option })
17 end
18 for i, object in ipairs(args.foreign_records) do
19 local selected = nil
20 if tostring(object[args.foreign_id]) == tostring(value) then
21 selected = "1"
22 end
23 ui_deprecated.tag("option", { html_options = { value = object[args.foreign_id], selected = selected }, content = object[args.foreign_name] })
24 end
25 end }) -- /select
26 end }) -- /div
27 end }) -- /div
28 end
