F
Filament4mo ago
jjo63

Generating some template (e.g. DIV) into a Table resource view

Hi as I understand it there are "render hooks" that can be used to inject some additional content in different places on different types of page. I have a resource called ArchFile and when we present the table of records I'd like (within that page) to be able to include some additional HTML (defines some divs needed for a modal iframe). My knowledge again is inadequate to understand how to achieve this. I was reading here https://filamentphp.com/docs/3.x/support/render-hooks and thought that this would be an appropriate use for my needs:
FilamentView::registerRenderHook(
TablesRenderHook::HEADER_AFTER,
fn (): View => view('my_extra_html'),);
FilamentView::registerRenderHook(
TablesRenderHook::HEADER_AFTER,
fn (): View => view('my_extra_html'),);
The documentation says
To register render hooks, you can call FilamentView::registerRenderHook() from a service provider or middleware.
I am not sure what that means but I'm guessing that my ArchFileResource.php file is not the place. In a default install of Filament, where might i add this code? Thanks for all help & comments, j
1 Reply
jjo63
jjo63OP4mo ago
Hi I did some further reading and felt that where I had the code was correct - I changed the HEADER_AFTER to be TOOLBAR_END and then was able to make it work. As it's some definition of DIVs that are hidden until required, I am not too concerned at this time where on the page the HTML is actually generated. But the documentation suggested that HEADER_AFTER was valid - however at runtime that results in a
Undefined constant Filament\Tables\View\TablesRenderHook::HEADER_AFTER
My error or something wrong in Filament? Thx j
Want results from more Discord servers?
Add your server