How to customize label when selecting relationship???
I have a database like below and I am creating details_unit table and I select details_capacity table. I want when selecting a table label to display the ingredient table name and capacity table description instead of displaying ingredient_id or capacity_id, what should I do?
7 Replies
share code
I just started using filament recently, my code is in Select::make('detail_capacity_id')
->relationship(name: 'detailCapacity',
titleAttribute: 'ingredient_id') is displaying ingredient_id, I want it to display the name of the ingredient table and description of the capacity table, what should I do?
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->name} {$record->capacity->description}")
like thisThank you very very very very very much
You're welcome.. next time please wrap code using triple backtick mentioned in #✅┊rules