From 759a3724b56ecc0fe9adeca3573cb3e2e5a1c519 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Aug 2021 23:09:56 +1000 Subject: [PATCH] Add function to extract all data from a displayed form --- InvenTree/templates/js/translated/forms.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index 3b55802f38..a31da2529d 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -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. *