Software /
code /
prosody
Comparison
util/dataforms.lua @ 1945:adfd7f3720f5
util.dataforms: Small fix to allow generating forms without specifying any input data
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 10 Oct 2009 03:09:15 +0100 |
parent | 1944:754eebd31538 |
child | 1958:e2b0026143c4 |
comparison
equal
deleted
inserted
replaced
1944:754eebd31538 | 1945:adfd7f3720f5 |
---|---|
35 for n, field in ipairs(layout) do | 35 for n, 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[field.name] or field.value; | 40 local value = (data and data[field.name]) or field.value; |
41 | 41 |
42 -- Add value, depending on type | 42 -- Add value, depending on type |
43 if field_type == "hidden" then | 43 if field_type == "hidden" then |
44 if type(value) == "table" then | 44 if type(value) == "table" then |
45 -- Assume an XML snippet | 45 -- Assume an XML snippet |