webmcp
diff framework/env/ui_deprecated/field.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/field.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,34 @@ 1.4 +-- 1.5 +-- Creates an output field 1.6 +-- 1.7 +-- label (string) The label of the field 1.8 +-- value (atom) The value to put out 1.9 +-- field_type (string) The type of the field (default: 'string') 1.10 +-- 1.11 +-- Example: 1.12 +-- 1.13 +-- ui_deprecated.field({ 1.14 +-- label = _'Id', 1.15 +-- value = myobject.id, 1.16 +-- field_type = 'integer' 1.17 +-- }) 1.18 +-- 1.19 + 1.20 +function ui_deprecated.field(args) 1.21 + local value_type = args.value_type or atom.string 1.22 + slot.put( 1.23 + '<div class="ui_field ui_field_', value_type.name, '">', 1.24 + '<div class="label">', 1.25 + encode.html(args.label or ''), 1.26 + '</div>', 1.27 + '<div class="value">') 1.28 + if args.value then 1.29 + slot.put(encode.html(convert.to_human(args.value, value_type))) 1.30 + elseif args.link then 1.31 + ui_deprecated.link(args.link) 1.32 + end 1.33 + slot.put( 1.34 + '</div>', 1.35 + '</div>\n' 1.36 + ) 1.37 +end