webmcp

diff framework/env/ui/field/integer.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/field/integer.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,28 @@
     1.4 +--[[--
     1.5 +ui.field.integer{
     1.6 +  ...                              -- generic ui.field.* arguments, as described for ui.autofield{...}
     1.7 +  format_options = format_options  -- format options for format.decimal
     1.8 +}
     1.9 +
    1.10 +This function inserts a field for an integer in the active slot. For description of the generic field helper arguments, see help for ui.autofield{...}.
    1.11 +
    1.12 +--]]--
    1.13 +
    1.14 +function ui.field.integer(args)
    1.15 +  ui.form_element(args, {fetch_value = true}, function(args)
    1.16 +    local value_string = format.decimal(args.value, args.format_options)
    1.17 +    if args.readonly then
    1.18 +      ui.tag{ tag = args.tag, attr = args.attr, content = value_string }
    1.19 +    else
    1.20 +      local attr = table.new(args.attr)
    1.21 +      attr.type  = "text"
    1.22 +      attr.name  = args.html_name
    1.23 +      attr.value = value_string
    1.24 +      ui.tag{ tag  = "input", attr = attr }
    1.25 +      ui.hidden_field{
    1.26 +        name  = args.html_name .. "__format",
    1.27 +        value = encode.format_info("decimal", args.format_options)
    1.28 +      }
    1.29 +    end
    1.30 +  end)
    1.31 +end

Impressum / About Us