aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-07-07 12:11:52 +0100
committerMatthew Wild <mwild1@gmail.com>2018-07-07 12:11:52 +0100
commit554651a23b04a2b0239878e46528fbd36b1443ae (patch)
tree1118a7795fbc821dabb5995c1ffc9a093c98859b /util
parente77ed7aa89bed8c74aff5ed9ec706ee35e35c6dd (diff)
downloadprosody-554651a23b04a2b0239878e46528fbd36b1443ae.tar.gz
prosody-554651a23b04a2b0239878e46528fbd36b1443ae.zip
util.dataforms: More robust handling of field values, especially booleans
Ensure that a non-nil data[field_name] always overrides the field's default, and that values of boolean 'false' are always rendered in the form.
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index e48f6879..64f73c11 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -42,9 +42,14 @@ function form_t.form(layout, data, formtype)
form:text_tag("desc", field.desc);
end
- local value = (data and data[field.name]) or field.value;
+ local value;
+ if data and data[field.name] ~= nil then
+ value = data[field.name];
+ else
+ value = field.value;
+ end
- if value then
+ if value ~= nil then
-- Add value, depending on type
if field_type == "hidden" then
if type(value) == "table" then