mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Logic fix for boolean fields in JS forms
(cherry picked from commit 10dec7743e
)
This commit is contained in:
parent
d75ce451be
commit
88fc0393b7
@ -811,7 +811,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?
|
||||
@ -2034,8 +2036,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