diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index d5a5f16487..47e3337a20 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -169,16 +169,8 @@ function constructForm(url, method, options={}) { } -/* - * Construct a 'creation' (POST) form, to create a new model in the database. - * - * arguments: - * - fields: The 'actions' object provided by the OPTIONS endpoint - * - * options: - * - - */ -function constructCreateForm(url, fields, options={}) { + +function constructFormBody(url, fields, options={}) { var html = ''; @@ -250,6 +242,22 @@ function constructCreateForm(url, fields, options={}) { } +/* + * Construct a 'creation' (POST) form, to create a new model in the database. + * + * arguments: + * - fields: The 'actions' object provided by the OPTIONS endpoint + * + * options: + * - + */ +function constructCreateForm(url, fields, options={}) { + + // We should have enough information to create the form! + constructFormBody(url, fields, options); +} + + /* * Construct a 'change' (PATCH) form, to create a new model in the database. * @@ -280,7 +288,7 @@ function constructChangeForm(url, fields, options={}) { } } - constructCreateForm(url, fields, options); + constructFormBody(url, fields, options); }, error: function(request, status, error) { // TODO: Handle error here @@ -446,6 +454,11 @@ function constructInputOptions(name, classes, type, parameters) { opts.push(`type='${type}'`); + // Read only? + if (parameters.read_only) { + opts.push(`readonly=''`); + } + if (parameters.value) { // Existing value? opts.push(`value='${parameters.value}'`);