FilamentF
Filament3y ago
core

Forms\Components\Select: relationship with json column list?

how can I return a parsed list using a relationship when the db field is a json, (get only the "title, or parse by locale)?
  Forms\Components\Select::make('related_dishes')
                                    ->preload()
                                    ->multiple()
                                    ->label('Related Dishes')
                                    ->relationship('relatedDishes', 'title') 
                                    ->placeholder('Select a Related Dish'),
,
Screenshot_2023-12-10_at_17.34.48.png
Solution
try using
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
Was this page helpful?