Skip to content

Commit c7101f9

Browse files
committed
fill form with data from basemodel
1 parent ca641e9 commit c7101f9

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/Entities/Items/Draft/Pages/BaseEditDraft.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ public function mount($record): void
3232
public function mutateFormDataBeforeFill(array $data): array
3333
{
3434
$record = $this->getRecord();
35-
35+
$values = $data;
36+
3637
if (! method_exists($record, 'getTranslation') || ! property_exists($record, 'translatedAttributes')) {
37-
return $data;
38+
return $values;
3839
}
39-
40+
4041
$translatable = $record->translatedAttributes;
41-
$values = [];
4242
foreach ($translatable as $attr) {
4343
$translation = $record->getTranslation($this->lang, false);
4444
$values[$attr] = $translation ? $translation->$attr : $record->$attr;
4545
}
46-
46+
4747
return $values;
4848
}
4949

src/Entities/Items/Draft/Pages/BaseViewDraft.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ public function mount($record): void
2626
public function mutateFormDataBeforeFill(array $data): array
2727
{
2828
$record = $this->getRecord();
29+
$values = $data;
2930

30-
if (! method_exists($record, 'getTranslation') || ! property_exists($record, 'translatedAttributes')) {
31-
return $data;
32-
}
33-
34-
$translatable = $record->translatedAttributes;
35-
$values = [];
36-
foreach ($translatable as $attr) {
37-
$translation = $record->getTranslation($this->lang, false);
38-
$values[$attr] = $translation ? $translation->$attr : $record->$attr;
31+
if (method_exists($record, 'getTranslation') && property_exists($record, 'translatedAttributes')) {
32+
$translatable = $record->translatedAttributes;
33+
foreach ($translatable as $attr) {
34+
$translation = $record->getTranslation($this->lang, false);
35+
$values[$attr] = $translation ? $translation->$attr : $record->$attr;
36+
}
3937
}
4038

4139
return $values;

0 commit comments

Comments
 (0)