Fixes call to processField (#5943)

* Fixes call to processField

- Previously used options.fields?
- Should use fields?

* Update forms.js
This commit is contained in:
Oliver 2023-11-20 22:03:08 +11:00 committed by GitHub
parent 65531f7611
commit 0d7b4f2f17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) {