How can you customize record title on attach action

Hello, I would like to know if it's possible to customize record title more than just a different attribute. I would like to combine multiple attributes in to one title. Is it possible? Thanks for any help in advance...
No description
Solution:
Tables\Actions\AttachAction::make()
->recordTitle(fn (Model $record): string => "{$record->id} {$record->start}")
Tables\Actions\AttachAction::make()
->recordTitle(fn (Model $record): string => "{$record->id} {$record->start}")
https://github.com/filamentphp/filament/discussions/13096#discussioncomment-9674355...
GitHub
How can you customize record title on attach action · filamentphp f...
Package Table builder Package Version v3.2.83 How can we help you? Hello, I would like to know if it's possible to customize record title more than just a different attribute. I would like to c...
Jump to solution
8 Replies
awcodes
awcodes5w ago
Assuming this is a relationship ->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->first_name} {$record->last_name}")
Groli
Groli5w ago
That's what I tried It just resulted in lowercase name of model being the the opton title for every record
->headerActions([
Tables\Actions\AttachAction::make()
->form(fn(AttachAction $action): array => [
$action->getRecordSelect()
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->id} {$record->start}")
]),
])
->headerActions([
Tables\Actions\AttachAction::make()
->form(fn(AttachAction $action): array => [
$action->getRecordSelect()
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->id} {$record->start}")
]),
])
Groli
Groli5w ago
No description
Groli
Groli5w ago
id is a string with nine chars and a start is an integer so this doesn't make sense to me
Solution
LeandroFerreira
Tables\Actions\AttachAction::make()
->recordTitle(fn (Model $record): string => "{$record->id} {$record->start}")
Tables\Actions\AttachAction::make()
->recordTitle(fn (Model $record): string => "{$record->id} {$record->start}")
https://github.com/filamentphp/filament/discussions/13096#discussioncomment-9674355
GitHub
How can you customize record title on attach action · filamentphp f...
Package Table builder Package Version v3.2.83 How can we help you? Hello, I would like to know if it's possible to customize record title more than just a different attribute. I would like to c...
Groli
Groli5w ago
Thank you so much, I didn't know I can do it like this.
nowak
nowak4w ago
Just spent a long time trying to get this to work before finally finding AttachAction::make()->recordTitle(). This needs to be added to https://filamentphp.com/docs/3.x/panels/resources/relation-managers#attaching-and-detaching-records
awcodes
awcodes4w ago
There’s a link at the bottom of the page. Feel free to submit a PR to update it.