Skip to content

Commit

Permalink
Merge pull request #10 from tuner7777/2.x
Browse files Browse the repository at this point in the history
The issue with modifying the item list during saving has been fixed.
  • Loading branch information
alexvenga authored Jan 19, 2025
2 parents 810ede8 + 218ecd0 commit 254dc42
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Fields/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ public function hasFields(): bool
return true;
}

protected function resolveOnApply(): ?Closure
{
return function ($item) {
$translations = $this->requestValue() !== false
? collect($this->requestValue())->mapWithKeys(function ($item) {
return [$item['key'] => $item['value']];
})->toArray()
: $item->getTranslations($this->column());

$item->replaceTranslations($this->column(), $translations);

return $item;
};
}

protected function resolvePreview(): View|string
{
return $this?->data?->{$this->column()} ?? '';
Expand Down

0 comments on commit 254dc42

Please sign in to comment.