Display field prefix element in form

This commit is contained in:
Oliver 2021-06-28 21:38:42 +10:00
parent ac7564d069
commit ed2f21f583
2 changed files with 15 additions and 1 deletions

View File

@ -45,6 +45,10 @@
method: 'POST',
title: '{% trans "Edit Part Details" %}',
fields: {
title: {
prefix: `<span class='fas fa-user'></span>`
},
reference: {},
part: {
filters: {
}

View File

@ -275,6 +275,9 @@ function constructFormBody(fields, options) {
// Edit callback
fields[field].onEdit = field_options.onEdit;
// Field prefix
fields[field].prefix = field_options.prefix;
}
}
@ -835,14 +838,21 @@ function constructField(name, parameters, options) {
html += `<div class='controls'>`;
if (parameters.prefix) {
html += `<div class='input-group'><span class='input-group-addon'>${parameters.prefix}</span>`;
}
html += constructInput(name, parameters, options);
if (parameters.prefix) {
html += `</div>`; // input-group
}
if (parameters.help_text) {
html += constructHelpText(name, parameters, options);
}
html += `</div>`; // controls
html += `</div>`; // form-group
return html;