Software /
code /
prosody
Comparison
util/dataforms.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Aug 2013 17:48:21 +0200 |
parent | 5693:ef490e9276df |
child | 6149:2ae6e9063e88 |
comparison
equal
deleted
inserted
replaced
5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
---|---|
1 -- Prosody IM | 1 -- Prosody IM |
2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local setmetatable = setmetatable; | 9 local setmetatable = setmetatable; |
36 local field_type = field.type or "text-single"; | 36 local field_type = field.type or "text-single"; |
37 -- Add field tag | 37 -- Add field tag |
38 form:tag("field", { type = field_type, var = field.name, label = field.label }); | 38 form:tag("field", { type = field_type, var = field.name, label = field.label }); |
39 | 39 |
40 local value = (data and data[field.name]) or field.value; | 40 local value = (data and data[field.name]) or field.value; |
41 | 41 |
42 if value then | 42 if value then |
43 -- Add value, depending on type | 43 -- Add value, depending on type |
44 if field_type == "hidden" then | 44 if field_type == "hidden" then |
45 if type(value) == "table" then | 45 if type(value) == "table" then |
46 -- Assume an XML snippet | 46 -- Assume an XML snippet |
91 form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up(); | 91 form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up(); |
92 end | 92 end |
93 end | 93 end |
94 end | 94 end |
95 end | 95 end |
96 | 96 |
97 if field.required then | 97 if field.required then |
98 form:tag("required"):up(); | 98 form:tag("required"):up(); |
99 end | 99 end |
100 | 100 |
101 -- Jump back up to list of fields | 101 -- Jump back up to list of fields |
102 form:up(); | 102 form:up(); |
103 end | 103 end |
104 return form; | 104 return form; |
105 end | 105 end |