diff --git a/src/TranslatableFieldMixin.php b/src/TranslatableFieldMixin.php index 4a2da7f..24528ee 100644 --- a/src/TranslatableFieldMixin.php +++ b/src/TranslatableFieldMixin.php @@ -102,9 +102,20 @@ public function translatable() $this->fillUsing(function ($request, $model, $attribute, $requestAttribute) use ($locales) { $realAttribute = FieldServiceProvider::normalizeAttribute($this->meta['translatable']['original_attribute'] ?? $attribute); $translations = $request->{$realAttribute}; - foreach ($locales as $localeKey => $localeName) { - $model->translate($localeKey)->{$realAttribute} = $translations[$localeKey]; + + if($request->editMode == 'create') { + + foreach ($locales as $localeKey => $localeName) { + $translationEntry = $model->translateOrNew($localeKey); + + $translationEntry->{$realAttribute} = $translations[$localeKey]; + } + } else { + foreach ($locales as $localeKey => $localeName) { + $model->translate($localeKey)->{$realAttribute} = $translations[$localeKey]; + } } + }); return $this;