aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-08-03 22:55:28 +0200
committerKim Alvefur <zash@zash.se>2018-08-03 22:55:28 +0200
commit1601e8c4d28dedce3f335b51a45a9d78792a7779 (patch)
treea3583f57f879d743c0ab5b477c5275e88767357b /util
parent42f3addb8f298f9f9d277f739d51e9b15756aa56 (diff)
downloadprosody-1601e8c4d28dedce3f335b51a45a9d78792a7779.tar.gz
prosody-1601e8c4d28dedce3f335b51a45a9d78792a7779.zip
util.dataforms: Only allow overriding of options when passed via the :form method
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 72394fd8..45af72d1 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -50,18 +50,17 @@ function form_t.form(layout, data, formtype)
end
end
- local value;
+ local value = field.value;
+ local options = field.options;
+
if data and data[field.name] ~= nil then
value = data[field.name];
- else
- value = field.value;
- end
- local options = field.options;
- if formtype == "form" and value
- and (field_type == "list-single" or field_type == "list-multi") then
- -- Allow passing dynamically generated options as values
- options, value = value, nil;
+ if formtype == "form" and type(value) == "table"
+ and (field_type == "list-single" or field_type == "list-multi") then
+ -- Allow passing dynamically generated options as values
+ options, value = value, nil;
+ end
end
if formtype == "form" and options then