Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The function getColumns() in a custom dashboard is not working #15464

Open
tabatii opened this issue Jan 29, 2025 · 1 comment
Open

The function getColumns() in a custom dashboard is not working #15464

tabatii opened this issue Jan 29, 2025 · 1 comment
Labels
Milestone

Comments

@tabatii
Copy link

tabatii commented Jan 29, 2025

Package

filament/filament

Package Version

v3.2.135

Laravel Version

v11.41.0

Livewire Version

v.3.5.12

PHP Version

8.2.9

Problem description

I have specified 3 columns in the function getColumns() but my widgets still showing in a 2 columns layout
The function getColumns() in a custom dashboard does not work if my widgets are not discovered
I'm using this line in my widget class to prevent the widgets from showing on other dashboards
protected static bool $isDiscovered = false;
Apparently when i remove this line from the widgets the function getColumns() starts working as expected

Expected behavior

Expect the dashboard to have 3 columns instead of 2

Steps to reproduce

Clone the repo
Migrate the database php artisan migrate
Create a filament user php artisan make:filament-user
Login to the dashboard
You will see that the widgets are showing in a 2 columns layout even when i specify 3 columns in the function getColumns() in my custom dashboard class App\Filament\Pages\Dashboard

Reproduction repository (issue will be closed if this is not valid)

https://github.com/tabatii/filament-dashboard-columns-bug

Relevant log output

@tabatii tabatii added bug Something isn't working medium priority unconfirmed labels Jan 29, 2025
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Jan 29, 2025
@danharrin danharrin added this to the v3 milestone Feb 3, 2025
@jayson-temporas
Copy link

jayson-temporas commented Feb 5, 2025

@tabatii This is not a bug. You placed your widgets in the footer widgets section.
The number of footer widget columns is managed separately using the getFooterWidgetsColumns method.

<?php

namespace App\Filament\Pages;

use Filament\Pages\Dashboard as BaseDashboard;

class Dashboard extends BaseDashboard
{
    /**
     * @return int | string | array<string, int | string | null>
     */
    public function getFooterWidgetsColumns(): int | string | array
    {
        return 3;
    }

    protected function getFooterWidgets(): array
    {
        return [
            \App\Filament\Widgets\UsersChart::class,
            \App\Filament\Widgets\PostsChart::class,
            \App\Filament\Widgets\ProductsChart::class,
        ];
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants