webmcp
view framework/env/ui/field/text.lua @ 3:795b764629ca
Version 1.0.3
Important bugfix related to internal forwards (Bug was introduced by the restriction of views with underscore prefix in Version 1.0.2)
Important bugfix related to internal forwards (Bug was introduced by the restriction of views with underscore prefix in Version 1.0.2)
author | jbe |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | 9fdfb27f8e67 |
children |
line source
1 --[[--
2 ui.field.text{
3 ... -- generic ui.field.* arguments, as described for ui.autofield{...}
4 format_options = format_options -- format options for format.string
5 }
7 This function inserts a field for a text in the active slot. For description of the generic field helper arguments, see help for ui.autofield{...}.
9 --]]--
11 function ui.field.text(args)
12 ui.form_element(args, {fetch_value = true}, function(args)
13 local value_string = format.string(args.value, args.format_options)
14 if args.readonly then
15 ui.tag{ tag = args.tag, attr = args.attr, content = value_string }
16 else
17 local attr = table.new(args.attr)
18 attr.name = args.html_name
19 if args.multiline then
20 ui.tag { tag = "textarea", attr = attr, content = value_string }
21 else
22 attr.type = "text"
23 attr.value = value_string
24 ui.tag{ tag = "input", attr = attr }
25 end
26 end
27 end)
28 end