Comparison

util/dataforms.lua @ 954:72e4639c9310

util.dataforms: Fixes for hidden field type
author Matthew Wild <mwild1@gmail.com>
date Sat, 04 Apr 2009 18:07:48 +0100
parent 953:bed748f5dbb1
child 955:98ca5a753fee
comparison
equal deleted inserted replaced
953:bed748f5dbb1 954:72e4639c9310
1 local setmetatable = setmetatable; 1 local setmetatable = setmetatable;
2 local pairs, ipairs = pairs, ipairs; 2 local pairs, ipairs = pairs, ipairs;
3 local tostring, type = tostring, type;
4 local t_concat = table.concat;
5
3 local st = require "util.stanza"; 6 local st = require "util.stanza";
4 7
5 module "dataforms" 8 module "dataforms"
6 9
7 local xmlns_forms = 'jabber:x:data'; 10 local xmlns_forms = 'jabber:x:data';
32 35
33 -- Add value, depending on type 36 -- Add value, depending on type
34 if field_type == "hidden" then 37 if field_type == "hidden" then
35 if type(value) == "table" then 38 if type(value) == "table" then
36 -- Assume an XML snippet 39 -- Assume an XML snippet
37 form:add_child(value); 40 form:tag("value")
41 :add_child(value)
42 :up();
38 elseif value then 43 elseif value then
39 form:tag("value"):text(tostring(value)); 44 form:tag("value"):text(tostring(value)):up();
40 end 45 end
41 elseif field_type == "boolean" then 46 elseif field_type == "boolean" then
42 form:tag("value"):text((value and "1") or "0"):up(); 47 form:tag("value"):text((value and "1") or "0"):up();
43 elseif field_type == "fixed" then 48 elseif field_type == "fixed" then
44 49