Software /
code /
prosody
Diff
util/dataforms.lua @ 9242:68694c1bd960
util.dataforms: Allow field names to be different from the 'var' attribute
This should allow the usage of long prefixes and namespace-like names to
be contained to the XML representation of the form, so that the code can
use more convenient names.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 01 Sep 2018 01:24:46 +0200 |
parent | 9121:e5eb36ee07a2 |
child | 9243:a4c52e304e6f |
line wrap: on
line diff
--- a/util/dataforms.lua Mon Sep 03 17:45:30 2018 +0100 +++ b/util/dataforms.lua Sat Sep 01 01:24:46 2018 +0200 @@ -42,7 +42,7 @@ for _, field in ipairs(layout) do local field_type = field.type or "text-single"; -- Add field tag - form:tag("field", { type = field_type, var = field.name, label = formtype ~= "submit" and field.label or nil }); + form:tag("field", { type = field_type, var = field.var or field.name, label = formtype ~= "submit" and field.label or nil }); if formtype ~= "submit" then if field.desc then @@ -150,7 +150,7 @@ for _, field in ipairs(layout) do local tag; for field_tag in stanza:childtags("field") do - if field.name == field_tag.attr.var then + if (field.var or field.name) == field_tag.attr.var then tag = field_tag; break; end