aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-10-16 19:52:09 +0100
committerMatthew Wild <mwild1@gmail.com>2009-10-16 19:52:09 +0100
commitfd9cf022178cbce84d643b38cbe77096319221f5 (patch)
treeb8a280f1526f80dc9535873b93c3b1afe6b251d9 /util
parent2139dc47e4a3acaea463fc799ca83b7e39fd517a (diff)
downloadprosody-fd9cf022178cbce84d643b38cbe77096319221f5.tar.gz
prosody-fd9cf022178cbce84d643b38cbe77096319221f5.zip
util.dataforms: Incorporate slightly modified patch for list-single type from Florob
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index b9fd23f2..46e22dc1 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -10,7 +10,6 @@ local setmetatable = setmetatable;
local pairs, ipairs = pairs, ipairs;
local tostring, type = tostring, type;
local t_concat = table.concat;
-
local st = require "util.stanza";
module "dataforms"
@@ -66,6 +65,14 @@ function form_t.form(layout, data)
for line in value:gmatch("([^\r\n]+)\r?\n*") do
form:tag("value"):text(line):up();
end
+ elseif field_type == "list-single" then
+ for _, val in ipairs(value) do
+ if type(val) == "table" then
+ form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+ else
+ form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
+ end
+ end
end
if field.required then
@@ -120,6 +127,9 @@ field_readers["text-multi"] =
return t_concat(result, "\n");
end
+field_readers["list-single"] =
+ field_readers["text-single"];
+
field_readers["boolean"] =
function (field_tag)
local value = field_tag:child_with_name("value");