diff --git a/src/lib/Form/DataTransformer/TranslatablePropertyTransformer.php b/src/lib/Form/DataTransformer/TranslatablePropertyTransformer.php index d541eefe48..2db053c7cb 100644 --- a/src/lib/Form/DataTransformer/TranslatablePropertyTransformer.php +++ b/src/lib/Form/DataTransformer/TranslatablePropertyTransformer.php @@ -36,9 +36,7 @@ public function transform($valueAsHash) public function reverseTransform($value) { - if (!$value) { - return null; - } + $value = (false === $value || [] === $value) ? null : $value; return [$this->languageCode => $value]; } diff --git a/src/lib/Tests/Form/DataTransformer/TranslatablePropertyTransformerTest.php b/src/lib/Tests/Form/DataTransformer/TranslatablePropertyTransformerTest.php index 0dab27f1dc..81dae0d851 100644 --- a/src/lib/Tests/Form/DataTransformer/TranslatablePropertyTransformerTest.php +++ b/src/lib/Tests/Form/DataTransformer/TranslatablePropertyTransformerTest.php @@ -60,8 +60,8 @@ public function testReverseTransform($inputValue, $languageCode, $expected) public function reverseTransformProvider() { return [ - [false, 'fre-FR', null], - [null, 'fre-FR', null], + [false, 'fre-FR', ['fre-FR' => null]], + [null, 'fre-FR', ['fre-FR' => null]], ['français', 'fre-FR', ['fre-FR' => 'français']], ['english', 'eng-GB', ['eng-GB' => 'english']], ['norsk', 'nor-NO', ['nor-NO' => 'norsk']],