X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fdataforms.lua;h=5a3b1fb5652c969fb1cc5e329dcae8dbca04613d;hb=92eedf5efe9d2043fa7b277ef57c62edf5032621;hp=5626172e15fc614e62ab99d568b32c4e684b8a9b;hpb=4d77a884366d92323198890f0893b5f599fc369f;p=prosody.git diff --git a/util/dataforms.lua b/util/dataforms.lua index 5626172e..5a3b1fb5 100644 --- a/util/dataforms.lua +++ b/util/dataforms.lua @@ -1,6 +1,6 @@ -- Prosody IM --- Copyright (C) 2008-2009 Matthew Wild --- Copyright (C) 2008-2009 Waqas Hussain +-- Copyright (C) 2008-2010 Matthew Wild +-- Copyright (C) 2008-2010 Waqas Hussain -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. @@ -23,8 +23,8 @@ function new(layout) return setmetatable(layout, form_mt); end -function form_t.form(layout, data) - local form = st.stanza("x", { xmlns = xmlns_forms, type = "form" }); +function form_t.form(layout, data, formtype) + local form = st.stanza("x", { xmlns = xmlns_forms, type = formtype or "form" }); if layout.title then form:tag("title"):text(layout.title):up(); end @@ -93,7 +93,13 @@ function form_t.data(layout, stanza) local data = {}; for field_tag in stanza:childtags() do - local field_type = field_tag.attr.type; + local field_type; + for n, field in ipairs(layout) do + if field.name == field_tag.attr.var then + field_type = field.type; + break; + end + end local reader = field_readers[field_type]; if reader then