Help with Global Search in Filament Relation Manager without a Resource

What I am trying to do:
I have a ProfileResource that contains a PcoFormSubmissionsRelationManager, there is no standalone Filament Resource for PcoFormSubmissionsResource. I want to enable the global search feature in FilamentPHP to search and retrieve the values of these form submissions by way of the submissionValues field. What I did:
- If the PcoFormSubmission had its own Filament Resource, I would typically use protected static ?string $recordTitleAttribute = 'submissionValues'; to make it searchable. - However, since this is a Relation Manager (and not a separate Resource), I am unsure how to achieve the same result. My issue/the error:
The global search does not seem to work for this Relation Manager setup. Has anyone successfully implemented global search for just a Relation Manager (without a Resource), or is there a way to search the submissions? Any advice or examples would be helpful. The table search is working fine, it's just the global search I'm struggling with. Code snippets from my setup: PcoFormSubmissionsRelationManager:
<?php

namespace App\Filament\Resources\ProfileResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use App\Models\PcoFormSubmission;

class PcoFormSubmissionsRelationManager extends RelationManager
{
protected static ?string $relationship = 'formSubmissions';
protected static ?string $recordTitleAttribute = 'submissionValues';

public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('submissionValues'),
])
->filters([/* Filters here */]);
}
}
<?php

namespace App\Filament\Resources\ProfileResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use App\Models\PcoFormSubmission;

class PcoFormSubmissionsRelationManager extends RelationManager
{
protected static ?string $relationship = 'formSubmissions';
protected static ?string $recordTitleAttribute = 'submissionValues';

public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('submissionValues'),
])
->filters([/* Filters here */]);
}
}
Thanks in advance for any insights!
3 Replies
awcodes
awcodes3mo ago
The DefaultGlobalSearchProvider only includes resources. Could possibly extend that and override to search other things. But relationship managers are setup to work with it directly.
awcodes
awcodes3mo ago
GitHub
filament/packages/panels/src/GlobalSearch/DefaultGlobalSearchProvid...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
Donnell Wyche
Donnell WycheOP3mo ago
@awcodes Thanks for replying. I hacked something together that works by overriding the ProfileResource global search functions, but that's not what I want to achieve. I guess I could make a Filament resource, then hide it from navigation to get the functionality I'm seeking. But I was in the midst of source diving to try to figure this out. If I create something less hackey, I'll reply with my solution.
Want results from more Discord servers?
Add your server