F
Filament12mo 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 Koch12mo ago
Where are your translations? In a translation file? Please format your code properly ( #✅┊rules )
Jessy
JessyOP12mo ago
in json file, in lang directory I tried also: ->getOptionLabelFromRecordUsing() but works only with relationship(), but I need options()
Solution
Dennis Koch
Dennis Koch12mo ago
You need to ->map() your names to the translated names.
Jessy
JessyOP12mo ago
ty

Did you find this page helpful?