From d87ab0033a18b5399d48eceb75db20300a4c4613 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 24 Aug 2021 22:05:00 +1000 Subject: [PATCH] Add "afterRender" callback for modal forms --- InvenTree/templates/js/translated/forms.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index 904053a423..292b1d89ad 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -258,6 +258,8 @@ function constructForm(url, options) { constructFormBody({}, options); } + options.fields = options.fields || {}; + // Save the URL options.url = url; @@ -517,6 +519,11 @@ function constructFormBody(fields, options) { initializeGroups(fields, options); + if (options.afterRender) { + // Custom callback function after form rendering + options.afterRender(fields, options); + } + // Scroll to the top $(options.modal).find('.modal-form-content-wrapper').scrollTop(0); }