Fixes boolean fields

main
Yasen Pramatarov 2024-11-02 17:33:18 +02:00
parent e90f4ca020
commit 83fd64cf51
2 changed files with 5 additions and 5 deletions

View File

@ -17,10 +17,10 @@ class Config {
// value is without quotes, because it could be true/false
$pattern = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/";
// prepare the value, treating booleans as 'true' or 'false'
if ($newValue === 1) {
// prepare the value, make booleans w/out single quotes
if ($newValue === 'true') {
$replacementValue = 'true';
} elseif ($newValue === 0) {
} elseif ($newValue === 'false') {
$replacementValue = 'false';
} else {
$replacementValue = var_export($newValue, true);

View File

@ -57,8 +57,8 @@ 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' : '' ?> />
<input type="hidden" name="<?= htmlspecialchars($config_item) ?>" value="false" />
<input class="form-check-input" type="checkbox" role="switch" name="<?= htmlspecialchars($config_item) ?>" value="true" <?= ($config_value === 1 || $config_value === true) ? 'checked' : '' ?> />
<?php } elseif ($config_item === 'environment') { ?>
<select class="form-control" type="text" name="<?= htmlspecialchars($config_item) ?>">
<option value="development"<?= ($config_value === 'development') ? ' selected' : '' ?>>development</option>