F
Filament12mo 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'),
Forms\Components\Select::make('related_dishes')
->preload()
->multiple()
->label('Related Dishes')
->relationship('relatedDishes', 'title')
->placeholder('Select a Related Dish'),
,
No description
Solution:
try using
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
...
Jump to solution
2 Replies
Solution
Lara Zeus
Lara Zeus12mo ago
try using
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
core
coreOP12mo ago
thanks
Want results from more Discord servers?
Add your server