Current Record in Render Hook
Hey!
I want to use the Render Hook
PanelsRenderHook::BODY_START
and render custom view depending on the current record. I specified the scope, so that it is only displayed on a specific resource page but struggle to get the current resource record in my new view in order to display the necessary information.
Does anyone know how the get or inject the current record in a render hook?2 Replies
So I came across your question as I had the same issue (getting the current record into a render hook).
I had seen elsewhere where
Filament::registerRenderHook
was being used in the getHeaderActions()
function call in individual Resource Pages, and I figured you could just pass the record along using $this->record()
. It works!
I've also used the booted() lifecycle hook which does the same. You then just get the record into the view, or pass it to a livewire component.
I would also bet you could just use Livewire events to pass whatever data you need to along to other Livewire components.
Is it the best way? Probably not, but it works for my needs until something "official" is known.you can check this too
https://filamentglow.com/trick/access-the-current-component-in-a-render-hook-183810e3