F
Filament9mo ago
ruddy

Adding an icon to the View option in a RelationManager tab

I'm using the hasCombinedRelationManagerTabsWithContent() method to add tabs to my resource ViewRecord, but I can't manage to add an icon to the View tab :( For the relation icons I did using the icon property.
public static function getRelations(): array
{
return [
//
RelationGroup::make('Consultas', [
RelationManagers\ConsultasRelationManager::class,
])->icon('heroicon-o-rectangle-stack'),
RelationGroup::make('Orcamentos', [
RelationManagers\OrcamentosRelationManager::class,
])->icon('heroicon-o-currency-dollar'),
];
}
public static function getRelations(): array
{
return [
//
RelationGroup::make('Consultas', [
RelationManagers\ConsultasRelationManager::class,
])->icon('heroicon-o-rectangle-stack'),
RelationGroup::make('Orcamentos', [
RelationManagers\OrcamentosRelationManager::class,
])->icon('heroicon-o-currency-dollar'),
];
}
No description
No description
14 Replies
Lara Zeus
Lara Zeus9mo ago
in the relation class protected static ?string $icon = 'heroicon-m-eye';
ruddy
ruddyOP9mo ago
yeah, did that on the relationmanager, but in the resource view option itself is not working similar to the <#1200379146287718460> question
Lara Zeus
Lara Zeus9mo ago
the Visualizar page is a relation? or view page? I see Consultas has an icon!
ruddy
ruddyOP9mo ago
a view page
Lara Zeus
Lara Zeus9mo ago
try add the $navigationIcon to the view class
ruddy
ruddyOP9mo ago
class ViewPaciente extends ViewRecord
{
protected static string $resource = PacienteResource::class;

protected static ?string $navigationIcon = 'heroicon-m-eye';

protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}

public function hasCombinedRelationManagerTabsWithContent(): bool
{
return true;
}
}
class ViewPaciente extends ViewRecord
{
protected static string $resource = PacienteResource::class;

protected static ?string $navigationIcon = 'heroicon-m-eye';

protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}

public function hasCombinedRelationManagerTabsWithContent(): bool
{
return true;
}
}
still nothing
Lara Zeus
Lara Zeus9mo ago
I am using it here, but been searching how and cant found it lol https://demo.larazeus.com/admin/forms/feedback this def works
class ViewForm extends ViewRecord
{
protected static ?string $navigationIcon = 'heroicon-o-user';

protected static string $resource = FormResource::class;
}
class ViewForm extends ViewRecord
{
protected static ?string $navigationIcon = 'heroicon-o-user';

protected static string $resource = FormResource::class;
}
ruddy
ruddyOP9mo ago
for me it doesnt, lol
No description
ruddy
ruddyOP9mo ago
using the following code
Lara Zeus
Lara Zeus9mo ago
really weird try $activeNavigationIcon and also use the getters function getNavigationIcon
ruddy
ruddyOP9mo ago
it's weird because if i use a record subnavigation it shows the icon, but in the relationmanager tab it doesn't :(
No description
ruddy
ruddyOP9mo ago
fixed that going to filament/resources/views/components/resources/relation-managers.blade.php view and passing the getNavigationIcon on the icon param on x-filament::tabs.item livewire component
<x-filament::tabs.item
:icon="filled($tabKey) ? ($isGroup ? $manager->getIcon() : $manager::getIcon($ownerRecord, $pageClass)) : $this->getNavigationIcon()"
>
@if (filled($tabKey))
{{ $isGroup ? $manager->getLabel() : $manager::getTitle($ownerRecord, $pageClass) }}
@elseif ($content)
{{ $contentTabLabel }}
@endif
</x-filament::tabs.item>
<x-filament::tabs.item
:icon="filled($tabKey) ? ($isGroup ? $manager->getIcon() : $manager::getIcon($ownerRecord, $pageClass)) : $this->getNavigationIcon()"
>
@if (filled($tabKey))
{{ $isGroup ? $manager->getLabel() : $manager::getTitle($ownerRecord, $pageClass) }}
@elseif ($content)
{{ $contentTabLabel }}
@endif
</x-filament::tabs.item>
Lara Zeus
Lara Zeus9mo ago
I hope you didnt edit the file in the vendor? I guess you're on older version!
ruddy
ruddyOP9mo ago
nope, running on latest version of filament. but nevermind, I just changed the relationmanager tab to a resource subnavigation that works fine with icons and looks the same :)
Want results from more Discord servers?
Add your server