Software /
code /
prosody
Diff
util/dataforms.lua @ 6981:bcaa553de6e8
util.dataforms: Track which fields are included in a form
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 08 Dec 2015 20:16:49 +0100 |
parent | 6830:e08f5d081a6c |
child | 7442:156c95bfed0b |
line wrap: on
line diff
--- a/util/dataforms.lua Tue Dec 08 20:12:38 2015 +0100 +++ b/util/dataforms.lua Tue Dec 08 20:16:49 2015 +0100 @@ -118,6 +118,7 @@ function form_t.data(layout, stanza) local data = {}; local errors = {}; + local present = {}; for _, field in ipairs(layout) do local tag; @@ -133,6 +134,7 @@ 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 @@ 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)