aboutsummaryrefslogtreecommitdiffstats
path: root/util/dataforms.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2010-07-15 22:58:10 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2010-07-15 22:58:10 +0200
commit1f7f8e57a3f5bbffdc261285c8ef46e9749e22d3 (patch)
tree8e8723d8b64e2c48933da9936e5b0f365b1ed175 /util/dataforms.lua
parent364d26fb31a876b48c5c51d92f4ee724fc4230b0 (diff)
downloadprosody-1f7f8e57a3f5bbffdc261285c8ef46e9749e22d3.tar.gz
prosody-1f7f8e57a3f5bbffdc261285c8ef46e9749e22d3.zip
util.dataforms: Add list-multi support
Diffstat (limited to 'util/dataforms.lua')
-rw-r--r--util/dataforms.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index f6a61f1f..7814ada0 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -79,6 +79,17 @@ function form_t.form(layout, data, formtype)
form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up();
end
end
+ elseif field_type == "list-multi" 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();
+ if 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
+ end
end
end
@@ -154,6 +165,17 @@ field_readers["text-multi"] =
field_readers["list-single"] =
field_readers["text-single"];
+field_readers["list-multi"] =
+ function (field_tag)
+ local result = {};
+ for value_tag in field_tag:childtags() do
+ if value_tag.name == "value" then
+ result[#result+1] = value_tag[1];
+ end
+ end
+ return result;
+ end
+
field_readers["boolean"] =
function (field_tag)
local value = field_tag:child_with_name("value");