F
Filamentβ€’3d 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
9 Replies
LeandroFerreira
LeandroFerreiraβ€’3d ago
you mean, inside the form, not this right?
aldec
aldecOPβ€’3d ago
I can't access your link, sorry
No description
LeandroFerreira
LeandroFerreiraβ€’3d ago
my bad, this
aldec
aldecOPβ€’3d 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β€’3d 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β€’3d 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β€’3d 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β€’3d ago
nice tip btw, I'll create a content about this πŸ˜…
aldec
aldecOPβ€’3d ago
Awesome! Thank you very much! This has the additional benefit of not having a page reload like the hasCombinedRelationManagerTabsWithContent method has
Want results from more Discord servers?
Add your server