Logic fix for boolean fields in JS forms

This commit is contained in:
Oliver 2021-11-22 21:46:45 +11:00
parent 8030ca0bb9
commit 10dec7743e

View File

@ -804,7 +804,9 @@ function updateFieldValue(name, value, field, options) {
switch (field.type) {
case 'boolean':
el.prop('checked', value);
if (value == true || value.toString().toLowerCase() == 'true') {
el.prop('checked');
}
break;
case 'related field':
// Clear?
@ -2019,8 +2021,15 @@ function constructInputOptions(name, classes, type, parameters) {
}
if (parameters.value != null) {
// Existing value?
opts.push(`value='${parameters.value}'`);
if (parameters.type == 'boolean') {
// Special consideration of a boolean (checkbox) value
if (parameters.value == true || parameters.value.toString().toLowerCase() == 'true') {
opts.push('checked');
}
} else {
// Existing value?
opts.push(`value='${parameters.value}'`);
}
} else if (parameters.default != null) {
// Otherwise, a defualt value?
opts.push(`value='${parameters.default}'`);