Mercurial > prosody-hg
comparison util/dataforms.lua @ 6679:96e034508978
Merge 0.10->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 13 May 2015 17:00:27 +0100 |
| parents | d6a60e74f773 |
| children | 5de6b93d0190 |
comparison
equal
deleted
inserted
replaced
| 6666:42fdc8dddf04 | 6679:96e034508978 |
|---|---|
| 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; |
| 10 local pairs, ipairs = pairs, ipairs; | 10 local ipairs = ipairs; |
| 11 local tostring, type, next = tostring, type, next; | 11 local tostring, type, next = tostring, type, next; |
| 12 local t_concat = table.concat; | 12 local t_concat = table.concat; |
| 13 local st = require "util.stanza"; | 13 local st = require "util.stanza"; |
| 14 local jid_prep = require "util.jid".prep; | 14 local jid_prep = require "util.jid".prep; |
| 15 | 15 |
| 30 form:tag("title"):text(layout.title):up(); | 30 form:tag("title"):text(layout.title):up(); |
| 31 end | 31 end |
| 32 if layout.instructions then | 32 if layout.instructions then |
| 33 form:tag("instructions"):text(layout.instructions):up(); | 33 form:tag("instructions"):text(layout.instructions):up(); |
| 34 end | 34 end |
| 35 for n, field in ipairs(layout) do | 35 for _, field in ipairs(layout) do |
| 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; |
