Skip to content

Commit

Permalink
fix error on empty update
Browse files Browse the repository at this point in the history
  • Loading branch information
bastihilger committed Feb 11, 2021
1 parent 6783217 commit 67149f7
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/TranslatableFieldMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,11 @@ public function translatable()
$realAttribute = FieldServiceProvider::normalizeAttribute($this->meta['translatable']['original_attribute'] ?? $attribute);
$translations = $request->{$realAttribute};

if($request->editMode == 'create') {

foreach ($locales as $localeKey => $localeName) {
$translationEntry = $model->translateOrNew($localeKey);
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];
}
$translationEntry->{$realAttribute} = $translations[$localeKey];
}

});

return $this;
Expand Down

0 comments on commit 67149f7

Please sign in to comment.