Skip to content

Commit 1842f55

Browse files
authored
Update locale handling to use strtolower and strtoupper
1 parent 737ab62 commit 1842f55

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Fields/Translations.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getLocales(): array
6868
public function resolveDisplay(Model $related): ?string
6969
{
7070
if (is_null($this->displayResolver)) {
71-
$this->display('locale');
71+
$this->display(fn (): string => strtoupper($related->locale));
7272
}
7373

7474
return parent::resolveDisplay($related);
@@ -93,10 +93,13 @@ public function fields(Request $request): array
9393
? $options
9494
: array_unique(array_merge([$model->locale], $options));
9595

96-
return array_combine($options, array_map('strtoupper', $options));
96+
return array_combine(
97+
array_map('strtolower', $options),
98+
array_map('strtoupper', $options)
99+
);
97100
})
98101
->required()
99-
->rules(['required', 'string', Rule::in(array_keys($this->getLocales()))]),
102+
->rules(['required', 'string', Rule::in(array_map('strtolower', $this->getLocales()))]),
100103
];
101104
}
102105
}

0 commit comments

Comments
 (0)