keys with empty string value are deleted #430
Unanswered
FrancoisDucobu
asked this question in
Q&A
Replies: 2 comments
-
Up |
Beta Was this translation helpful? Give feedback.
0 replies
-
The same issue, this is my temporary solution: override the // custom TranslateTrait overwrite filterTranslations
<?php
namespace App\Traits;
trait TranslateTrait
{
protected function filterTranslations(mixed $value = null, ?string $locale = null, ?array $allowedLocales = null): bool
{
if ($value === null) {
return false;
}
if ($value === '') {
return true; <-- edit this
}
if ($allowedLocales === null) {
return true;
}
if (! in_array($locale, $allowedLocales)) {
return false;
}
return true;
}
}
// Model file
use HasTranslations, TranslateTrait{
TranslateTrait::filterTranslations insteadof HasTranslations;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm facing an issue.
I found where this issue is happening but I don't know why the package do this behavior.
I try to save an empty string in the json but the package remove the associated key value.
below the SQL request
we can see in the SQL request that fr_FR key is missing.
I check in the package code and I found this in the HasTranslation.php trait
Is this the behaviour intended by the package?
Regards,
francois
Beta Was this translation helpful? Give feedback.
All reactions