getHeaderActions with custom header view

I'm using a custom header view, but it seems to be overwriting what's defined in my getHeaderActions method on my class. I've tried doing something like {{ $this->headerActions }} in my custom header blade view, but that doesn't seem to do it. How can I have a custom header AND header actions?
Solution:
Possibly: ``` <x-filament::actions :actions="$this->getCachedHeaderActions()” />...
Jump to solution
4 Replies
Jon Mason
Jon Mason3mo ago
or even better, can I pass the actions to the view in the getHeader method somehow? Doing this:
public function getHeader(): ?View
{
return view('components.layouts.headers.location-header', ['title' => $this->getTitle(), 'location' => $this->location, 'actions' => $this->getHeaderActions()]);
}
public function getHeader(): ?View
{
return view('components.layouts.headers.location-header', ['title' => $this->getTitle(), 'location' => $this->location, 'actions' => $this->getHeaderActions()]);
}
I can do this:
@foreach ($actions as $action)
@dump($action)
@endforeach
@foreach ($actions as $action)
@dump($action)
@endforeach
Which is heading in the right direction, but not sure how to actually render the action on the page.. Ah! it looks like just {{ $action }} will do it.. but it's not handling things correctly...I have 2 actions, only one of which will be visible, and all that is defined on my class. Once they're rendered it's just displaying all of them regardless. It looks like the button that shouldn't be visible is disabled at least, but it's still visible.
Solution
awcodes
awcodes3mo ago
Possibly:
<x-filament::actions
:actions="$this->getCachedHeaderActions()”
/>
<x-filament::actions
:actions="$this->getCachedHeaderActions()”
/>
awcodes
awcodes3mo ago
GitHub
filament/packages/panels/resources/views/components/header/index.bl...
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
GitHub
filament/packages/panels/resources/views/components/page/index.blad...
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
Jon Mason
Jon Mason3mo ago
ok, yep that fixed it, thanks!