Add function to extract all data from a displayed form

This commit is contained in:
Oliver Walters 2021-08-07 23:09:56 +10:00
parent 5448165ef3
commit 759a3724b5

View File

@ -564,6 +564,30 @@ function insertConfirmButton(options) {
} }
/*
* Extract all specified form values as a single object
*/
function extractFormData(fields, options) {
var data = {};
for (var idx = 0; idx < options.field_names.length; idx++) {
var name = options.field_names[idx];
var field = fields[name] || null;
if (!field) continue;
if (field.type == 'candy') continue;
data[name] = getFormFieldValue(name, field, options);
}
return data;
}
/* /*
* Submit form data to the server. * Submit form data to the server.
* *