aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2010-07-15 21:31:57 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2010-07-15 21:31:57 +0200
commit364d26fb31a876b48c5c51d92f4ee724fc4230b0 (patch)
tree456cca8047aa85faafe2b48cf05acaa21cf9cf68 /util
parented7bac60e1150960a169f5b280583d173c2497aa (diff)
downloadprosody-364d26fb31a876b48c5c51d92f4ee724fc4230b0.tar.gz
prosody-364d26fb31a876b48c5c51d92f4ee724fc4230b0.zip
util.dataforms: Capability to set default for list-single
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 5a3b1fb5..f6a61f1f 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -67,9 +67,14 @@ 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(value) do
if type(val) == "table" then
form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up();
+ if 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