From 0d7b4f2f17a0695a2b760c8eb2860b8c334fefb1 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 20 Nov 2023 22:03:08 +1100 Subject: [PATCH] Fixes call to processField (#5943) * Fixes call to processField - Previously used options.fields? - Should use fields? * Update forms.js --- InvenTree/templates/js/translated/forms.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index 652c744e19..e5b075942e 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -486,7 +486,15 @@ function extractNestedField(field_name, fields) { */ function constructFormBody(fields, options) { - var html = ''; + let html = ''; + + // Client must provide set of fields to be displayed, + // otherwise *all* fields will be displayed + const displayed_fields = options.fields || fields || {}; + + if(!options.fields) { + options.fields = displayed_fields; + } // add additional content as a header on top (provided as html by the caller) if (options.header_html) { @@ -516,13 +524,11 @@ function constructFormBody(fields, options) { } for (const [k,v] of Object.entries(fields)) { - processField(k, v, options.fields[k]); + if (options.fields && k in options.fields) { + processField(k, v, options.fields[k]); + } } - // Client must provide set of fields to be displayed, - // otherwise *all* fields will be displayed - var displayed_fields = options.fields || fields; - // Override default option values if a 'DELETE' form is specified if (options.method == 'DELETE') { if (!('confirm' in options)) {