F
Filament4mo ago
Carlos

Render component inside relation manager

Hi everyone, I'm trying to render a Livewire component inside a Filament RelationManager page using a custom trait with a render hook. Here's the method I'm using:
protected function registerFooterComponent(string $componentClass, array $props = []): void
{
FilamentView::registerRenderHook(
PanelsRenderHook::RESOURCE_RELATION_MANAGER_AFTER,
fn (): string => Livewire::mount($componentClass, $props)
);
}
protected function registerFooterComponent(string $componentClass, array $props = []): void
{
FilamentView::registerRenderHook(
PanelsRenderHook::RESOURCE_RELATION_MANAGER_AFTER,
fn (): string => Livewire::mount($componentClass, $props)
);
}
In my boot() method of a RelationManager, I call:
$this->registerFooterComponent(\App\Livewire\MyComponent::class, [
'record' => $this->getOwnerRecord(),
]);
$this->registerFooterComponent(\App\Livewire\MyComponent::class, [
'record' => $this->getOwnerRecord(),
]);
The Livewire component is mounted and the HTML wrapper is visible in the DOM (i.e., <div id="component-container">...</div>), but the actual content inside the component isn't displaying. I’ve also registered a JS file using:
FilamentView::registerRenderHook('panels::body.end', fn (): string => Blade::render("@vite('resources/js/my-component.js')"),
scopes: [
AnotherResourceRelationManager::class,
],
);
FilamentView::registerRenderHook('panels::body.end', fn (): string => Blade::render("@vite('resources/js/my-component.js')"),
scopes: [
AnotherResourceRelationManager::class,
],
);
Is there a better way to render Livewire components dynamically in a RelationManager?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?