Comparison

util/dataforms.lua @ 2219:9e1c6b6a2ee4

util.dataforms: Don't require type when parsing form XML
author Florian Zeitz
date Wed, 25 Nov 2009 19:58:19 +0000
parent 2070:25dc4b9d06b1
child 2488:08bfd7c96531
comparison
equal deleted inserted replaced
2169:c06fdb6b57bd 2219:9e1c6b6a2ee4
91 91
92 function form_t.data(layout, stanza) 92 function form_t.data(layout, stanza)
93 local data = {}; 93 local data = {};
94 94
95 for field_tag in stanza:childtags() do 95 for field_tag in stanza:childtags() do
96 local field_type = field_tag.attr.type; 96 local field_type;
97 for n, field in ipairs(layout) do
98 if field.name == field_tag.attr.var then
99 field_type = field.type;
100 break;
101 end
102 end
97 103
98 local reader = field_readers[field_type]; 104 local reader = field_readers[field_type];
99 if reader then 105 if reader then
100 data[field_tag.attr.var] = reader(field_tag); 106 data[field_tag.attr.var] = reader(field_tag);
101 end 107 end