Tim
tooltip
Probably this is obvious to most people, but it wasn't to me 🙂 I have found that the order is important, x-tooltip.html must be before x-tooltip.raw in your array.
This works:
->extraAttributes(fn ($record): array => [
'x-tooltip.html' => new HtmlString(),
'x-tooltip.raw' => new HtmlString('Test<br />Test'),
])
This doesn't:
->extraAttributes(fn ($record): array => [
'x-tooltip.raw' => new HtmlString('Test<br />Test'),
'x-tooltip.html' => new HtmlString(),
]),
12 replies
navigationitems override
I was struggling with the same thing, but I realised (after quite a bit of time 🤦♂️ ) I could just pass the NavigationItem array directly from the getRecordSubNavigation, and the URL would be taken in to account.
If you actually need the results from $page->generateNavigationItems then you can't do this, but otherwise you can potentially just pass the NavigationItems you need without using the $page->generateNavigationItems
This is what I did directly in the getRecordSubNavigation for a "parent" resource of "Event" (ie in the EventResource) and a "child" resource of "Session":
public static function getRecordSubNavigation(Page $page): array
{
return [
NavigationItem::make('Event Details')
->url(fn (): string => EventResource\Pages\EditEvent::getUrl(['record' => request('record')]))
->isActiveWhen(fn () => Route::currentRouteName() === 'filament.app.resources.events.edit'),
NavigationItem::make('Sessions')
->url(fn (): string => EventResource::getUrl('sessions.index', ['parent' => request('record')]))
->isActiveWhen(fn () => Route::is('filament.app.resources.events.sessions*'))
];
}
Please note that the URL to access the child resource needs to come from the parent resource (as in Anik's original question), ie EventResource::getUrl('sessions.index', ['parent' => request('record')]).
I literally love the flexibility and functionality of filament! Hopefully I am not encouraging people to use it in the wrong way!
4 replies