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