Skip to content

Commit 104ca86

Browse files
author
antoine
committed
Fix title + list fields formatters
1 parent a4f27db commit 104ca86

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/Form/Fields/Formatters/ListFormatter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ public function toFront(SharpFormField $field, $value)
3737
// It's a sub attribute (like mother:name)
3838
[$attribute, $subAttribute] = explode(':', $key);
3939
$itemArray[$key] = isset($item[$attribute][$subAttribute])
40-
? $itemField->formatter()->toFront($itemField, $item[$attribute][$subAttribute])
40+
? $itemField
41+
->formatter()
42+
->setDataLocalizations($this->dataLocalizations ?: [])
43+
->toFront($itemField, $item[$attribute][$subAttribute])
4144
: null;
4245
} else {
4346
$itemArray[$key] = isset($item[$key])
44-
? $itemField->formatter()->toFront($itemField, $item[$key])
47+
? $itemField
48+
->formatter()
49+
->setDataLocalizations($this->dataLocalizations ?: [])
50+
->toFront($itemField, $item[$key])
4551
: null;
4652
}
4753
});

src/Show/Fields/Formatters/ListFormatter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ public function toFront(SharpShowField $field, $value)
2222
// It's a sub attribute (like mother:name)
2323
[$attribute, $subAttribute] = explode(':', $key);
2424
$itemArray[$key] = isset($item[$attribute][$subAttribute])
25-
? $itemField->formatter()->toFront($itemField, $item[$attribute][$subAttribute])
25+
? $itemField
26+
->formatter()
27+
->setDataLocalizations($this->dataLocalizations ?: [])
28+
->toFront($itemField, $item[$attribute][$subAttribute])
2629
: null;
2730
} else {
2831
$itemArray[$key] = isset($item[$key])
29-
? $itemField->formatter()->toFront($itemField, $item[$key])
32+
? $itemField
33+
->formatter()
34+
->setDataLocalizations($this->dataLocalizations ?: [])
35+
->toFront($itemField, $item[$key])
3036
: null;
3137
}
3238
});

src/Utils/Fields/HandleFields.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ final public function applyFormatters(?array $attributes): ?array
7979
->merge($attributes)
8080
->map(function ($value, $key) {
8181
if (isset($this->pageTitleField) && $this->pageTitleField->key == $key) {
82-
return $this->pageTitleField->formatter()->toFront($this->pageTitleField, $value);
82+
return $this->pageTitleField
83+
->formatter()
84+
->setDataLocalizations($this->getDataLocalizations())
85+
->toFront($this->pageTitleField, $value);
8386
}
8487

8588
$field = $this->findFieldByKey($key);

0 commit comments

Comments
 (0)