Software /
code /
prosody
Diff
util/dataforms.lua @ 11877:593b141ba01c
util.dataforms: Coerce number values for boolean fields
Makes more sense than coercing to a string, which would always be
truthy.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 26 Oct 2021 15:15:57 +0200 |
parent | 11874:84f4c6957d62 |
child | 11878:bf6706057283 |
line wrap: on
line diff
--- a/util/dataforms.lua Tue Oct 26 13:35:04 2021 +0200 +++ b/util/dataforms.lua Tue Oct 26 15:15:57 2021 +0200 @@ -103,8 +103,11 @@ if value ~= nil then if type(value) == "number" then - -- TODO validate that this is ok somehow, eg check field.datatype - value = ("%g"):format(value); + if field_type == "boolean" then + value = value ~= 0; + else + value = ("%g"):format(value); + end end -- Add value, depending on type if field_type == "hidden" then