F
Filamentβ€’16mo ago
cwbmuller

Discover panel widgets without adding to primary dashboard page

I am trying to discover a number of components (that are used on custom pages) in a panel. However, if I use discoverWidgets they are automatically registered to the landing dashboard page no matter what I set in the ->widgets() or in the getHeaderWidgets() of the main dashboard. If I don't add the parent path of panel widgets to the discoverWidgets then the other pages cannot find the widget components. I've tried to access the discoverComponents() method directly to register the widgets, but it is a protected. Please help πŸ™
8 Replies
cwbmuller
cwbmullerOPβ€’16mo ago
Yup! That's where I have tried to manually set the Dashboard widgets using getHeaderWidgets
Patrick Boivin
Patrick Boivinβ€’16mo ago
So you can have auto-discovery and customize the widgets on a specific dashboard. What is the remaining issue?
cwbmuller
cwbmullerOPβ€’16mo ago
This seems to override the dashboard widgets to all the widgets in the panel ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') I only want the widgets in ->discoverWidgets(in: app_path('Filament/Widgets/Dashboard'), for: 'App\\Filament\\Widgets\\Dashboard') on the dashboard But if I do that then the other (page) widgets are not discoverable for the other pages anymore
Patrick Boivin
Patrick Boivinβ€’16mo ago
On your custom dashboard, have you tried something like this?
public function getWidgets(): array
{
return [
MyWidget::class,
// ...
];
}
public function getWidgets(): array
{
return [
MyWidget::class,
// ...
];
}
cwbmuller
cwbmullerOPβ€’16mo ago
Aha! Ok that worked πŸ™ That overwrote the discovered widgets I was trying with header and footer widget method
Patrick Boivin
Patrick Boivinβ€’16mo ago
Right, yeah. I just noticed that too in the base Dashboard class πŸ˜„
cwbmuller
cwbmullerOPβ€’16mo ago
Thank you so much πŸ’ͺ
Want results from more Discord servers?
Add your server