F
Filament13mo 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 Zeus13mo ago
try using
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->title}")
core
coreOP13mo ago
thanks

Did you find this page helpful?