F
Filamentβ€’2mo ago
Pscl

How to load widgets only on specific pages/dashboards?

Hey all, I am trying to achieve multiple dashboards with different widgets. But somehow All widgets are loaded on all dashboards. Using getHeaderWidgets is just adding the widget of the array 2nd time on the page.
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
This is loading all widgets an all pages. If I remove it and add widgets here:
->widgets([
MonthlyExpenseChartWidget::class
// Widgets\AccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
->widgets([
MonthlyExpenseChartWidget::class
// Widgets\AccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
All of these widgets are loaded on every dashboard page. I am confused πŸ˜„ Thx for help
Solution:
Check the source code of the Dashboard class. It has a getWidgets() class that you can overwrite with the wanted widgets.
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Kochβ€’2mo ago
Check the source code of the Dashboard class. It has a getWidgets() class that you can overwrite with the wanted widgets.
Pscl
Psclβ€’2mo ago
@Dennis Koch thank you!