From aa0237766515358c5dec4fccc588b1d5707128d5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 23 Jun 2021 22:25:53 +1000 Subject: [PATCH] Updates for field rendering --- InvenTree/templates/js/forms.js | 47 +++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index 8d74299975..c741530523 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -176,9 +176,14 @@ function constructCreateForm(url, fields, options={}) { var html = ''; for (const key in fields) { - //console.log('field:', key); - html += constructField(key, fields[key], options); + var field = fields[key]; + + console.log(key, field.label, field.help_text); + + var f = constructField(key, field, options); + + html += f; } var modal = '#modal-form'; @@ -218,16 +223,19 @@ function constructField(name, parameters, options={}) { html += constructLabel(name, parameters); html += `
`; - + html += constructInput(name, parameters, options); - html += constructHelpText(name, parameters, options); - + + if (parameters.help_text) { + html += constructHelpText(name, parameters, options); + } + // TODO: Add the "error message" - + html += `
`; // controls - + html += ``; // form-group - + return html; } @@ -247,15 +255,18 @@ function constructLabel(name, parameters) { label_classes += ' requiredField'; } - var html =''; + var html = `