F
Filament11mo ago
Jessy

how to translate the option in a Select?

Forms\Components\Select::make('website_type_id')
->label(__('Type'))
->options(WebsiteType::all()->pluck('name', 'id'))
->required(),
Forms\Components\Select::make('website_type_id')
->label(__('Type'))
->options(WebsiteType::all()->pluck('name', 'id'))
->required(),
I tried : ->options((WebsiteType::all()->pluck( ('name')), 'id')), but doesn't work.
Solution:
You need to ->map() your names to the translated names.
Jump to solution
4 Replies
Dennis Koch
Dennis Koch11mo ago
Where are your translations? In a translation file? Please format your code properly ( #✅┊rules )
Jessy
JessyOP11mo ago
in json file, in lang directory I tried also: ->getOptionLabelFromRecordUsing() but works only with relationship(), but I need options()
Solution
Dennis Koch
Dennis Koch11mo ago
You need to ->map() your names to the translated names.
Jessy
JessyOP11mo ago
ty
Want results from more Discord servers?
Add your server