mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Logic fix for boolean fields in JS forms
This commit is contained in:
parent
8030ca0bb9
commit
10dec7743e
@ -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}'`);
|
||||
|
Loading…
Reference in New Issue
Block a user