Simplify rendering of checkboxes in forms

- Display "inline" so they take up much less vertical space
This commit is contained in:
Oliver Walters 2021-08-14 01:05:06 +10:00
parent ba1ba67f87
commit ad844c4393

View File

@ -490,8 +490,6 @@ function constructFormBody(fields, options) {
// Attach clear callbacks (if required)
addClearCallbacks(fields, options);
attachToggle(modal);
$(modal + ' .select2-container').addClass('select-full-width');
$(modal + ' .select2-container').css('width', '100%');
@ -1528,13 +1526,14 @@ function constructField(name, parameters, options) {
html += `</div>`; // input-group
}
// Div for error messages
html += `<div id='errors-${name}'></div>`;
if (parameters.help_text) {
html += constructHelpText(name, parameters, options);
}
// Div for error messages
html += `<div id='errors-${name}'></div>`;
html += `</div>`; // controls
html += `</div>`; // form-group
@ -1699,6 +1698,10 @@ function constructInputOptions(name, classes, type, parameters) {
opts.push(`placeholder='${parameters.placeholder}'`);
}
if (parameters.type == 'boolean') {
opts.push(`style='float: right;'`);
}
if (parameters.multiline) {
return `<textarea ${opts.join(' ')}></textarea>`;
} else {
@ -1872,7 +1875,13 @@ function constructCandyInput(name, parameters, options) {
*/
function constructHelpText(name, parameters, options) {
var html = `<div id='hint_id_${name}' class='help-block'><i>${parameters.help_text}</i></div>`;
var style = '';
if (parameters.type == 'boolean') {
style = `style='display: inline;' `;
}
var html = `<div id='hint_id_${name}' ${style}class='help-block'><i>${parameters.help_text}</i></div>`;
return html;
}