F
Filament10mo ago
This PC

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?
No description
7 Replies
Vp
Vp10mo ago
share code
This PC
This PCOP10mo ago
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?
This PC
This PCOP10mo ago
No description
Vp
Vp10mo ago
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->name} {$record->capacity->description}") like this
This PC
This PCOP10mo ago
Thank you very very very very very much
Vp
Vp10mo ago
You're welcome.. next time please wrap code using triple backtick mentioned in #✅┊rules
Want results from more Discord servers?
Add your server