Table builder render hooks - scope not working

I'm trying to add a scope to the table render hook (TablesRenderHook::TOOLBAR_AFTER,) , apparently it's possible. In scope I tried to pass ExampleResource, Pages/ListExample or Tables/ExampleTable and nothing works. Works without scope.
4 Replies
toeknee
toeknee2w ago
Where do you see it can be scoped? The ones that can be scoped to the page class are mentioned can be scoped but I don't see TOOLBAR_AFTER stating it can be scoped anywhere.
UntouchG
UntouchGOP2w ago
Thanks for the answer. Maybe I misunderstand something?
No description
toeknee
toeknee2w ago
No you right Still knee deep in V3 so my v4 knowledge isnt' fully there. My apologise. Can you provide the code you are using for the render hook
UntouchG
UntouchGOP2w ago
I passed the scope variable to the view for the test, in this case (TablesRenderHook::TOOLBAR_AFTER) it is empty but for hooks marked 'can be scope' (PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE) it contains the class names
class AdminPanelProvider extends PanelProvider
{

public function boot()
{
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_AFTER,
//PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE,
fn(array $scopes): View => view('filament.resources.partners-resource.top-scroll', [
'scopes' => $scopes,
]),
scopes: [
PartnersResource::class,
PartnersTable::class,
ListPartners::class,
],

);
}
class AdminPanelProvider extends PanelProvider
{

public function boot()
{
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_AFTER,
//PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE,
fn(array $scopes): View => view('filament.resources.partners-resource.top-scroll', [
'scopes' => $scopes,
]),
scopes: [
PartnersResource::class,
PartnersTable::class,
ListPartners::class,
],

);
}

Did you find this page helpful?