diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index 4801ec77eb..46b2b21a87 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -366,6 +366,10 @@ function constructFormBody(fields, options) { // TODO: Refactor the following code with Object.assign (see above) + // "before" and "after" renders + fields[field].before = field_options.before; + fields[field].after = field_options.after; + // Secondary modal options fields[field].secondary = field_options.secondary; @@ -560,10 +564,15 @@ function submitFormData(fields, options) { var has_files = false; // Extract values for each field - options.field_names.forEach(function(name) { + for (var idx = 0; idx < options.fields_names.length; idx++) { + + var name = options.field_names[idx]; var field = fields[name] || null; + // Ignore visual fields + if (field && field.type == 'candy') continue; + if (field) { var value = getFormFieldValue(name, field, options); @@ -593,7 +602,7 @@ function submitFormData(fields, options) { } else { console.log(`WARNING: Could not find field matching '${name}'`); } - }); + } var upload_func = inventreePut; @@ -1279,6 +1288,11 @@ function renderModelData(name, model, data, parameters, options) { */ function constructField(name, parameters, options) { + // Shortcut for simple visual fields + if (parameters.type == 'candy') { + return constructCandyInput(name, parameters, options); + } + var field_name = `id_${name}`; // Hidden inputs are rendered without label / help text / etc @@ -1292,7 +1306,14 @@ function constructField(name, parameters, options) { form_classes += ' has-error'; } - var html = `