aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2017-09-26 17:24:25 +0100
committerMatthew Wild <mwild1@gmail.com>2017-09-26 17:24:25 +0100
commitd6833915bcfaeb6600c0af911102a8362e26e93e (patch)
tree575fdc7082baf42f3c7871cac1bc03d7fa65f905 /util
parent43e5d4df2985e069c52fb21e4636e3e44053d1bf (diff)
parent86ee041be81ad313a24c87b6e38f92fe4400cf17 (diff)
downloadprosody-d6833915bcfaeb6600c0af911102a8362e26e93e.tar.gz
prosody-d6833915bcfaeb6600c0af911102a8362e26e93e.zip
Merge 0.10->trunk
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua40
1 files changed, 22 insertions, 18 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 756f35a7..469ce976 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -68,33 +68,37 @@ function form_t.form(layout, data, formtype)
form:tag("value"):text(line):up();
end
elseif field_type == "list-single" then
- local has_default = false;
- for _, val in ipairs(field.options or value) do
- if type(val) == "table" then
- form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
- if value == val.value or val.default and (not has_default) then
- form:tag("value"):text(val.value):up();
- has_default = true;
+ if formtype ~= "result" then
+ local has_default = false;
+ for _, val in ipairs(field.options or value) do
+ if type(val) == "table" then
+ form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+ if value == val.value or val.default and (not has_default) then
+ form:tag("value"):text(val.value):up();
+ has_default = true;
+ end
+ else
+ form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
end
- else
- form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
end
end
- if field.options and value then
+ if (field.options or formtype == "result") and value then
form:tag("value"):text(value):up();
end
elseif field_type == "list-multi" then
- for _, val in ipairs(field.options or value) do
- if type(val) == "table" then
- form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
- if not field.options and val.default then
- form:tag("value"):text(val.value):up();
+ if formtype ~= "result" then
+ for _, val in ipairs(field.options or value) do
+ if type(val) == "table" then
+ form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+ if not field.options and val.default then
+ form:tag("value"):text(val.value):up();
+ end
+ else
+ form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
end
- else
- form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
end
end
- if field.options and value then
+ if (field.options or formtype == "result") and value then
for _, val in ipairs(value) do
form:tag("value"):text(val):up();
end