F
Filament6mo ago
Groli

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
awcodes6mo ago
Assuming this is a relationship ->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->first_name} {$record->last_name}")
Groli
GroliOP6mo 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
GroliOP6mo ago
No description
Groli
GroliOP6mo ago
id is a string with nine chars and a start is an integer so this doesn't make sense to me
Solution
LeandroFerreira
LeandroFerreira6mo ago
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
GroliOP6mo ago
Thank you so much, I didn't know I can do it like this.
nowak
nowak6mo 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
awcodes6mo ago
There’s a link at the bottom of the page. Feel free to submit a PR to update it.
Want results from more Discord servers?
Add your server