Skip to content

Commit

Permalink
fix setting the state for creation and edit
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Mar 12, 2024
1 parent 96882ef commit 95fea40
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Forms/Components/MultiLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
}

0 comments on commit 95fea40

Please sign in to comment.