Relation manager in custom page
I have a custom page and I need to use the relation manager table in it.
This is the page. How can I add that relation manager table?
3 Replies
shouldn't you do it through getFormSchema method ?
You can either just embed a table (see the table builder docs) or have a look at the
edit-records.blade.php
on how relation managers are loaded with the default pages.I was able to add a relationship manager to a custom page using the following blade setup. I just created a new relation manager class (just a random PHP class, not in a resource) by copying / pasting the format.
<x-filament-panels::page>
<x-filament-panels::form wire:submit="update">
{{ $this->form }}
{{-- // add form actions --}}
<x-filament-panels::form.actions
:actions="$this->getFormActions()"
/>
</x-filament-panels::form>
@php
$relationManagers = $this->getRelationManagers();
// dd($relationManagers);
@endphp
<x-filament-panels::resources.relation-managers
:active-locale="null"
:active-manager="0"
:content-tab-label="'Tab'"
:managers="$relationManagers"
:owner-record="$record"
:page-class="static::class"
>
</x-filament-panels::resources.relation-managers>
</x-filament-panels::page>
$record is just a model assigned in the mount() method, and this is how I'm pulling in the relation manager class.
public function getRelationManagers(): array
{
return [
LicenseRelationManager::class
];
}
One last note: :active-manager="0" is just an array key, so could be controlled dynamically. I haven't tried it with multiple managers yet.