mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
ConfigForm: Use transformEmptyValuesToNull() also in onSuccess()
refs #2751
This commit is contained in:
parent
9791e6ffb8
commit
9ed5685849
@ -57,11 +57,7 @@ class ConfigForm extends Form
|
|||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
$sections = array();
|
$sections = array();
|
||||||
foreach ($this->getValues() as $sectionAndPropertyName => $value) {
|
foreach (static::transformEmptyValuesToNull($this->getValues()) as $sectionAndPropertyName => $value) {
|
||||||
if ($value === '' || $value === false || $value === []) {
|
|
||||||
$value = null; // Causes the config writer to unset it
|
|
||||||
}
|
|
||||||
|
|
||||||
list($section, $property) = explode('_', $sectionAndPropertyName, 2);
|
list($section, $property) = explode('_', $sectionAndPropertyName, 2);
|
||||||
$sections[$section][$property] = $value;
|
$sections[$section][$property] = $value;
|
||||||
}
|
}
|
||||||
@ -137,8 +133,12 @@ class ConfigForm extends Form
|
|||||||
*/
|
*/
|
||||||
public static function transformEmptyValuesToNull(array $values)
|
public static function transformEmptyValuesToNull(array $values)
|
||||||
{
|
{
|
||||||
return array_map(function ($v) {
|
array_walk($values, function (&$v) {
|
||||||
return ($v === '' || $v === false || $v === []) ? null : $v;
|
if ($v === '' || $v === false || $v === array()) {
|
||||||
}, $values);
|
$v = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return $values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user