Software /
code /
prosody
Diff
util/dataforms.lua @ 8984:fa80b3231a02
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.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 07 Jul 2018 12:11:52 +0100 |
parent | 8945:cbeb1a045eb6 |
child | 9047:ab3488ee3ca5 |
line wrap: on
line diff
--- a/util/dataforms.lua Fri Jul 06 19:02:19 2018 +0200 +++ b/util/dataforms.lua Sat Jul 07 12:11:52 2018 +0100 @@ -42,9 +42,14 @@ 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