Software / code / prosody
Diff
util/dataforms.lua @ 9121:e5eb36ee07a2
util.dataforms: Allow passing the current values to be used in stead of omitted fields
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 05 Aug 2018 15:50:06 +0200 |
| parent | 9111:bc7473fb7ad3 |
| child | 9242:68694c1bd960 |
line wrap: on
line diff
--- a/util/dataforms.lua Sun Aug 05 19:12:49 2018 +0200 +++ b/util/dataforms.lua Sun Aug 05 15:50:06 2018 +0200 @@ -142,7 +142,7 @@ local field_readers = {}; -function form_t.data(layout, stanza) +function form_t.data(layout, stanza, current) local data = {}; local errors = {}; local present = {}; @@ -157,7 +157,9 @@ end if not tag then - if field.required then + if current and current[field.name] ~= nil then + data[field.name] = current[field.name]; + elseif field.required then errors[field.name] = "Required value missing"; end elseif field.name then