webmcp

diff framework/env/ui_deprecated/select.lua @ 0:9fdfb27f8e67

Version 1.0.0
author jbe/bsw
date Sun Oct 25 12:00:00 2009 +0100 (2009-10-25)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/framework/env/ui_deprecated/select.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +function ui_deprecated.select(args)
     1.5 +  local record = assert(slot.get_state_table(), "ui_deprecated.select was not called within a form.").form_record
     1.6 +  local value = param.get(args.field) or record[args.field]
     1.7 +  local html_options = args.html_options or {}
     1.8 +  html_options.name = args.field
     1.9 +  
    1.10 +  ui_deprecated.tag("div", { html_options = { class="ui_field ui_select" }, content = function()
    1.11 +    if args.label then
    1.12 +      ui_deprecated.tag("div", { html_options = { class="label" }, content = function()
    1.13 +        ui_deprecated.text(args.label)
    1.14 +      end })
    1.15 +    end
    1.16 +    ui_deprecated.tag("div", { html_options = { class="value" }, content = function()
    1.17 +      ui_deprecated.tag("select", { html_options = html_options, content = function()
    1.18 +        if args.include_option then
    1.19 +          ui_deprecated.tag("option", { html_options = { value = "" }, content = args.include_option })
    1.20 +        end
    1.21 +        for i, object in ipairs(args.foreign_records) do
    1.22 +          local selected = nil
    1.23 +          if tostring(object[args.foreign_id]) == tostring(value) then
    1.24 +            selected = "1"
    1.25 +          end
    1.26 +          ui_deprecated.tag("option", { html_options = { value = object[args.foreign_id], selected = selected }, content = object[args.foreign_name] })
    1.27 +        end
    1.28 +      end }) -- /select
    1.29 +    end }) -- /div
    1.30 +  end }) -- /div
    1.31 +end
    1.32 +
    1.33 +
    1.34 +

Impressum / About Us