F
Filament6d ago
Matt

Customize option labels in a relation manager attach action

I need to customize the option labels in a relation manager attach action. I have tried the following
Tables\Actions\AttachAction::make()
->recordSelect(function (Forms\Components\Select $select) {
return $select
->getOptionLabelFromRecordUsing(fn ($record) => "{$record->id}. $record->name");
}),
Tables\Actions\AttachAction::make()
->recordSelect(function (Forms\Components\Select $select) {
return $select
->getOptionLabelFromRecordUsing(fn ($record) => "{$record->id}. $record->name");
}),
But that gets overwritten, still only showing the record title attribute defined in the relationship I'm not getting any errors, it just isn't working. Does anyone have any ideas?
1 Reply
Bruno Pereira
Bruno Pereira6d ago
It's not on the action itself. You must define
$table
->recordTitle(fn (User $record): string => "{$record->name} ({$record->email})")
$table
->recordTitle(fn (User $record): string => "{$record->name} ({$record->email})")
This is a snippet of my code, you have to change the Model to the correct one and change the fields to show in the select option. in my case when I search the select the options well be: john doe ([email protected])

Did you find this page helpful?