F
Filamentβ€’4w ago
aldec

Combine Relationship Manager tabs and form tabs

Is it possible to combine the tab created from hasCombinedRelationManagerTabsWithContent() with the tabs from a form?
Solution:
much better: ```php Livewire::make(YourRelationManager::class, fn (Page $livewire, YourModel $record) => [ 'ownerRecord' => $record,...
Jump to solution
10 Replies
LeandroFerreira
LeandroFerreiraβ€’4w ago
you mean, inside the form, not this right?
aldec
aldecOPβ€’4w ago
I can't access your link, sorry
No description
LeandroFerreira
LeandroFerreiraβ€’4w ago
my bad, this
aldec
aldecOPβ€’4w ago
Yes, I used this and now I have tabs for Edit and the Relations and below this tabs from the form. It would be nice to combine them into a single row.
No description
LeandroFerreira
LeandroFerreiraβ€’4w ago
it could be better, but it should work: in the RelationManager class, add this:
public function mount(): void
{
$this->ownerRecord = YourModel::find(request()->route('record'));
$pageClass = str(request()->route()->getAction('controller'))->remove('@__invoke')->toString();
$this->pageClass = $pageClass;

parent::mount();
}
public function mount(): void
{
$this->ownerRecord = YourModel::find(request()->route('record'));
$pageClass = str(request()->route()->getAction('controller'))->remove('@__invoke')->toString();
$this->pageClass = $pageClass;

parent::mount();
}
In the Form tab:
use Filament\Forms\Components\Livewire;
...

Tabs\Tab::make('xx')
->schema([
Livewire::make(YourRelationManager::class)
])
use Filament\Forms\Components\Livewire;
...

Tabs\Tab::make('xx')
->schema([
Livewire::make(YourRelationManager::class)
])
aldec
aldecOPβ€’4w ago
YourModel in the RelationManager refers to target model. For my use case right now this should work, but a more reusable solution would be nice. Thanks so far!
Solution
LeandroFerreira
LeandroFerreiraβ€’4w ago
much better:
Livewire::make(YourRelationManager::class, fn (Page $livewire, YourModel $record) => [
'ownerRecord' => $record,
'pageClass' => $livewire::class,
]),
Livewire::make(YourRelationManager::class, fn (Page $livewire, YourModel $record) => [
'ownerRecord' => $record,
'pageClass' => $livewire::class,
]),
and remove the mount method
LeandroFerreira
LeandroFerreiraβ€’4w ago
nice tip btw, I'll create a content about this πŸ˜…
aldec
aldecOPβ€’4w ago
Awesome! Thank you very much! This has the additional benefit of not having a page reload like the hasCombinedRelationManagerTabsWithContent method has
aldec
aldecOPβ€’3w ago
Hey, I'm coming back to this, feeling stupid that I didn't notice it earlier: 1. It is still necessary to load the RelationManager in the resources getRelations method, otherwise I can't create new entries (symfony error not finding the component), but then I have it under each form visible again... bummer. 2. Having this Livewire component in my tabs seems to hijack the form submit process, because nothing happens if i try to edit a form where this Livewire
Want results from more Discord servers?
Add your server