Fixes boolean fields in conf editing
parent
5220ab7fcd
commit
e90f4ca020
|
@ -17,8 +17,16 @@ class Config {
|
|||
// value is without quotes, because it could be true/false
|
||||
$pattern = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/";
|
||||
|
||||
// prepare the value and replace it
|
||||
$replacementValue = var_export($newValue, true);
|
||||
// prepare the value, treating booleans as 'true' or 'false'
|
||||
if ($newValue === 1) {
|
||||
$replacementValue = 'true';
|
||||
} elseif ($newValue === 0) {
|
||||
$replacementValue = 'false';
|
||||
} else {
|
||||
$replacementValue = var_export($newValue, true);
|
||||
}
|
||||
|
||||
// value replacing
|
||||
$config_contents = preg_replace($pattern, "$1{$replacementValue},", $config_contents);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ function editConfig($configPart, $indent, $platform=false, $parent='') {
|
|||
?>
|
||||
<div class="col-md-8 text-start">
|
||||
<?php if ($config_item === 'registration_enabled') { ?>
|
||||
<input type="hidden" name="<?= htmlspecialchars($config_item) ?>" value="0" />
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="<?= htmlspecialchars($config_item) ?>" value="<?= htmlspecialchars($config_value ?? 0) ?>" <?= ($config_value === 1 || $config_value === true) ? 'checked' : '' ?> />
|
||||
<?php } elseif ($config_item === 'environment') { ?>
|
||||
<select class="form-control" type="text" name="<?= htmlspecialchars($config_item) ?>">
|
||||
|
|
Loading…
Reference in New Issue