Another unwanted spaces at the end of a line.
[prosody.git] / util / dataforms.lua
index a57e183b007d0f776d5e9e20275cc10c11ed1c7e..ed62f9b185dfdc60a23ca287987344d9c9e14617 100644 (file)
@@ -1,3 +1,11 @@
+-- Prosody IM
+-- Copyright (C) 2008-2009 Matthew Wild
+-- Copyright (C) 2008-2009 Waqas Hussain
+-- 
+-- This project is MIT/X11 licensed. Please see the
+-- COPYING file in the source package for more information.
+--
+
 local setmetatable = setmetatable;
 local pairs, ipairs = pairs, ipairs;
 local tostring, type = tostring, type;
@@ -16,10 +24,8 @@ function new(layout)
        return setmetatable(layout, form_mt);
 end
 
-local form_x_attr = { xmlns = xmlns_forms };
-
 function form_t.form(layout, data)
-       local form = st.stanza("x", form_x_attr);
+       local form = st.stanza("x", { xmlns = xmlns_forms, type = "form" });
        if layout.title then
                form:tag("title"):text(layout.title):up();
        end
@@ -31,7 +37,7 @@ function form_t.form(layout, data)
                -- Add field tag
                form:tag("field", { type = field_type, var = field.name, label = field.label });
 
-               local value = data[field.name];
+               local value = data[field.name] or field.value;
                
                -- Add value, depending on type
                if field_type == "hidden" then