F
Filament4mo ago
daniik

TableRenderHook Action

Hi, I'm trying to add my button action to the table next to the filters. For some reason, the slideOver modal doesn't open and the action just disappears. How do I correctly add the hook for that action?
public function mount(): void
{
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_END,
function () {
return Blade::render('{{ $action }} <x-filament-actions::modals />', [
'action' => $this->getGraphAction()
]);
}
);
}

private function getGraphAction(): Action
{
return \Filament\Tables\Actions\Action::make('graphs')
->iconButton()
->icon('heroicon-o-chart-pie')
->iconSize(IconSize::Large)
->size(ActionSize::ExtraLarge)
->color('success')
->slideOver()
->modalContent(View::make('filament.widgets.tracker-graphs-widget'))
->modalHeading('')
->modalSubmitAction(false)
->modalCancelAction(false);
}
public function mount(): void
{
FilamentView::registerRenderHook(
TablesRenderHook::TOOLBAR_END,
function () {
return Blade::render('{{ $action }} <x-filament-actions::modals />', [
'action' => $this->getGraphAction()
]);
}
);
}

private function getGraphAction(): Action
{
return \Filament\Tables\Actions\Action::make('graphs')
->iconButton()
->icon('heroicon-o-chart-pie')
->iconSize(IconSize::Large)
->size(ActionSize::ExtraLarge)
->color('success')
->slideOver()
->modalContent(View::make('filament.widgets.tracker-graphs-widget'))
->modalHeading('')
->modalSubmitAction(false)
->modalCancelAction(false);
}
9 Replies
toeknee
toeknee4mo ago
Try adding
->action(fn() => true)
->action(fn() => true)
daniik
daniikOP4mo ago
Thanks, but still same
toeknee
toeknee4mo ago
try
->form([
ViewField::make('graphs-widget')->view('filament.widgets.tracker-graphs-widget')
])
->form([
ViewField::make('graphs-widget')->view('filament.widgets.tracker-graphs-widget')
])
daniik
daniikOP4mo ago
Didn't help as well
toeknee
toeknee4mo ago
That's interesting, sounds like it's not actually being loaded properly then
daniik
daniikOP4mo ago
When I add this action to headerActions, it opens and loads fine, no problem. I'm not sure how to put it in the hook so that it opens. Or is it necessary to regenerate/rebuild something?
toeknee
toeknee4mo ago
I think try rendering it with livewire opposed to blade
LeandroFerreira
LeandroFerreira4mo ago
I don't think it will work if you are using it in the mount method.. 🤔
daniik
daniikOP4mo ago
Any other ideas how to mount it? Generaly I'm open for any idea.

Did you find this page helpful?