diff --git a/src/Forms/Components/MultiLang.php b/src/Forms/Components/MultiLang.php index 62e3db5..c15e0c7 100644 --- a/src/Forms/Components/MultiLang.php +++ b/src/Forms/Components/MultiLang.php @@ -7,4 +7,23 @@ class MultiLang extends TextInput { protected string $view = 'zeus-chaos::forms.components.multi-lang'; + + protected function setUp(): void + { + parent::setUp(); + $this->formatStateUsing(function () { + $defaultDataForLang = []; + + foreach (config('app.locales') as $lang => $info) { + if (static::getRecord() === null) { + $defaultDataForLang[$lang] = ''; + } else { + // @phpstan-ignore-next-line + $defaultDataForLang[$lang] = static::getRecord()->getTranslation('name', $lang); + } + } + + return $defaultDataForLang; + }); + } }