fix: [instance:settings] Normalise value before saving
parent
7fc2c595d7
commit
6a89e65a37
|
@ -49,6 +49,7 @@ class SettingsTable extends AppTable
|
|||
{
|
||||
$errors = [];
|
||||
$setting = $this->getSetting($name);
|
||||
$value = $this->normaliseValue($value, $setting);
|
||||
if (!empty($setting['beforeSave'])) {
|
||||
$setting['value'] = $value ?? '';
|
||||
$beforeSaveResult = $this->SettingsProvider->evaluateFunctionForSetting($setting['beforeSave'], $setting);
|
||||
|
@ -67,6 +68,14 @@ class SettingsTable extends AppTable
|
|||
return $errors;
|
||||
}
|
||||
|
||||
private function normaliseValue($value, $setting)
|
||||
{
|
||||
if ($setting['type'] == 'boolean') {
|
||||
return (bool) $value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function readSettings()
|
||||
{
|
||||
return Configure::read()[$this::$CONFIG_KEY];
|
||||
|
|
|
@ -126,7 +126,7 @@ function isLeaf($setting)
|
|||
const $input = $(this)
|
||||
const $inputGroup = $(this).closest('.form-group')
|
||||
const settingName = $(this).data('setting-name')
|
||||
const settingValue = $(this).is(':checked')
|
||||
const settingValue = $(this).is(':checked') ? 1 : 0
|
||||
saveSetting($inputGroup[0], $input, settingName, settingValue)
|
||||
} else {
|
||||
handleSettingValueChange($(this))
|
||||
|
|
Loading…
Reference in New Issue