aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-08-03 21:45:55 +0200
committerKim Alvefur <zash@zash.se>2018-08-03 21:45:55 +0200
commit383dc3fbfd49e6a86dd1a2b51bf49ecaa063a47b (patch)
tree0bad451843bd6f15735705da6a937f3ed476fdab /util
parent03cb4290344d3732c5b15d793ac13748a552990a (diff)
downloadprosody-383dc3fbfd49e6a86dd1a2b51bf49ecaa063a47b.tar.gz
prosody-383dc3fbfd49e6a86dd1a2b51bf49ecaa063a47b.zip
util.dataforms: Exclude descriptive text fields from forms of type 'submit'
The receiving end presumably already have the original form, so these potentially long text fields are of little value.
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 5a856abe..649676f8 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -31,19 +31,23 @@ function form_t.form(layout, data, formtype)
if formtype == "cancel" then
return form;
end
- if layout.title then
- form:tag("title"):text(layout.title):up();
- end
- if layout.instructions then
- form:tag("instructions"):text(layout.instructions):up();
+ if formtype ~= "submit" then
+ if layout.title then
+ form:tag("title"):text(layout.title):up();
+ end
+ if layout.instructions then
+ form:tag("instructions"):text(layout.instructions):up();
+ end
end
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 = field.label });
+ form:tag("field", { type = field_type, var = field.name, label = formtype ~= "submit" and field.label or nil });
- if field.desc then
- form:text_tag("desc", field.desc);
+ if formtype ~= "submit" then
+ if field.desc then
+ form:text_tag("desc", field.desc);
+ end
end
local value;
@@ -120,7 +124,7 @@ function form_t.form(layout, data, formtype)
form:up();
end
- if field.required then
+ if formtype == "form" and field.required then
form:tag("required"):up();
end