FilamentF
Filament13mo ago
taz

multiple filtersForm on a custom Livewire page

Is it possible to define multiple filtersForm on the same page.
It like to use it in my view like this {{ $this->secondFiltersForm }} in another place in the template.

The view
<div class="flex flex-col gap-y-4">
    <div>
        {{ $this->filtersForm }}
    </div>
    <div>   @livewire(\App\Filament\Widgets\TeamOverviewWidget::class, (property_exists($this, 'filters') ? ['filters' => $this->filters] : []))
    </div>
    <div>
        @livewire(\App\Filament\Widgets\GlobalIncomeChart::class, (property_exists($this, 'filters') ? ['filters' => $this->filters] : []))
    </div>

class Dashboard extends Page implements HasActions, HasForms
{
    use InteractsWithActions;
    use InteractsWithForms;
    use BaseDashboard\Concerns\HasFiltersForm;

    protected static string $view = 'filament.pages.dashboard';

    public function filtersForm(Form $form): Form
    {
        return $form
            ->schema([
                Section::make()
                        Select::make('income')
                            ->native(false)
                            ->selectablePlaceholder(false)
                            ->options([
                                'gross' => 'Gross',
                                'net' => 'Net'
                            ])
                            ->default('gross'),
                 
    }
Was this page helpful?