Select realtionship with translation

Select::make('course_id')
->label(__('Course'))
->relationship('course', 'name')
Select::make('course_id')
->label(__('Course'))
->relationship('course', 'name')
the options is not casted
No description
Solution:
thanks , this should work however I solved it using
->getOptionLabelFromRecordUsing(fn ($record) => $record->name)
->getOptionLabelFromRecordUsing(fn ($record) => $record->name)
...
Jump to solution
4 Replies
SLy
SLy17mo ago
Try ->relationship('course', 'name->' . app()->getLocale())
Solution
Mohamed Melouk
Mohamed Melouk17mo ago
thanks , this should work however I solved it using
->getOptionLabelFromRecordUsing(fn ($record) => $record->name)
->getOptionLabelFromRecordUsing(fn ($record) => $record->name)
SLy
SLy17mo ago
Yes, that too, meanwhile I have an issue with multiselect not working with translatable values, I get Uncaught (in promise) Could not find Livewire component in DOM tree when switching language and values are not translated, did you happen to have this situation working?
Mohamed Melouk
Mohamed MeloukOP17mo ago
yeah I got it I removed localswither and used https://filamentphp.com/plugins/language-switch it's not the best solution but it's the only I found
Filament
Language Switch by Bezhan Salleh - Plugins - Filament
Zero config Language Switch(Changer/Localizer) plugin for Filamentphp Admin

Did you find this page helpful?