Added Boolean Support

Added support to convert Boolean from 'on' to 1 in order for compatibility with the common object.
This commit is contained in:
Matt Sidnell 2020-04-15 12:53:39 +01:00 committed by GitHub
parent 1177f017f7
commit 98ffdfd1c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,6 +75,8 @@ if ($action == 'add' && !empty($permissiontoadd))
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} elseif ($object->fields[$key]['type'] == 'boolean') {
$value = (GETPOST($key) == 'on' ? 1 : 0);
} else {
$value = GETPOST($key, 'alphanohtml');
}
@ -156,6 +158,8 @@ if ($action == 'update' && !empty($permissiontoadd))
}
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} elseif ($object->fields[$key]['type'] == 'boolean') {
$value = (GETPOST($key) == 'on' ? 1 : 0);
} else {
$value = GETPOST($key, 'alpha');
}