How to show more information in RelationManager Attach Search.
I have a RelationManager that allows users to Attach records from any of their authorized tenants. I would like to show the tenant name next to the line in the search box so the user knows they're attaching the record from the correct tenant. For example, if both tenants have records called "Corporate Department" I'd like the list in the search box to show as "Corporate Department (Tenant A), Corporate Department (Tenant B).
I tried to use https://filamentphp.com/docs/3.x/panels/resources/relation-managers#searching-the-options-to-attach-across-multiple-columns
but just got an error when i tried to use agency.name as one of my columns (as you would in the table builder).
Solution:Jump to solution
Just edited mine to be ...
```php
Tables\Actions\AttachAction::make()
->recordSelectSearchColumns(['name', 'email'])...
4 Replies
You need recordTitle() ... here's how I do it, for pretty much the exact same reason, I need to add the user's email after the name, to make sure the right John Smith is selected ... "John Smith - [email protected]"
Note that I had to PR a fix on recordTitle() a week or so ago to make it work, so you'll need to be running a recent Filament version.
And of course you can use a fat arrow fn() if you want, I think I just used a function(){} because I was debugging it.
And I didn't typehint the $record, apparently. I'm going to hell.
Solution
Just edited mine to be ...
so here's a question because I apparently don't know how to use composer. my composer.json is set for filament to be
but when I run artisan filament:upgrade and then composer show filament/filament it says i'm still on 3.0.73. I don't know what i'm doing wrong.
“filament/filament”: “^3.0”