Software /
code /
prosody
Comparison
util/dataforms.lua @ 957:34f8cda285c4
util.dataforms: Allow form layouts to specify default values for fields
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 05 Apr 2009 19:42:01 +0100 |
parent | 956:4c3f3d60a2f4 |
child | 1522:569d58d21612 |
comparison
equal
deleted
inserted
replaced
956:4c3f3d60a2f4 | 957:34f8cda285c4 |
---|---|
27 for n, field in ipairs(layout) do | 27 for n, field in ipairs(layout) do |
28 local field_type = field.type or "text-single"; | 28 local field_type = field.type or "text-single"; |
29 -- Add field tag | 29 -- Add field tag |
30 form:tag("field", { type = field_type, var = field.name, label = field.label }); | 30 form:tag("field", { type = field_type, var = field.name, label = field.label }); |
31 | 31 |
32 local value = data[field.name]; | 32 local value = data[field.name] or field.value; |
33 | 33 |
34 -- Add value, depending on type | 34 -- Add value, depending on type |
35 if field_type == "hidden" then | 35 if field_type == "hidden" then |
36 if type(value) == "table" then | 36 if type(value) == "table" then |
37 -- Assume an XML snippet | 37 -- Assume an XML snippet |