aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-12-08 20:16:49 +0100
committerKim Alvefur <zash@zash.se>2015-12-08 20:16:49 +0100
commitdb9b82199fdc9ea3fee6c032c03bebcdd669f4a0 (patch)
tree372c8d3937ba9e638457ead8718a2f0df363306c
parent2458f50dcae3f60055a9f79e8a9c91dd1b28fc46 (diff)
downloadprosody-db9b82199fdc9ea3fee6c032c03bebcdd669f4a0.tar.gz
prosody-db9b82199fdc9ea3fee6c032c03bebcdd669f4a0.zip
util.dataforms: Track which fields are included in a form
-rw-r--r--util/dataforms.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 05846ab3..79b4d1a4 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -118,6 +118,7 @@ local field_readers = {};
function form_t.data(layout, stanza)
local data = {};
local errors = {};
+ local present = {};
for _, field in ipairs(layout) do
local tag;
@@ -133,6 +134,7 @@ function form_t.data(layout, stanza)
errors[field.name] = "Required value missing";
end
else
+ present[field.name] = true;
local reader = field_readers[field.type];
if reader then
data[field.name], errors[field.name] = reader(tag, field.required);
@@ -140,9 +142,9 @@ function form_t.data(layout, stanza)
end
end
if next(errors) then
- return data, errors;
+ return data, errors, present;
end
- return data;
+ return data, nil, present;
end
local function simple_text(field_tag, required)