Custom page with InteractsWithForms trait - select field issue

Hello,

I'm having an issue on my custom page where I've added the "InteractsWithForms" trait to incorporate a form.
I've created the form(Form $form) function that returns a form (in my case, a special filter for my page). In this form, I have "DatePicker," "Select," "TextInput," and "ToggleButtons" fields.
I have an applyFilter function that allows me to filter my data. The problem is that I can retrieve the values from each field except for those from the "Select" fields. Moreover, if I set the fields to required, the select fields generate an error during the form validation as if the selected value was not taken into account. Where could the problem be coming from?

Here is the simplified code :
    public ?array $customFilters = [];

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Select::make('sondage_id')
                    ->label('Groupe sélectionné')
                    ->options([
                        1 => "Participants", 
                        2 => "Formateurs"
                    ]),
            ])
            ->statePath('customFilters');
    }

    public function applyFilter(): void
    {
        dd($this->form->getState());
    }


The html :
<form wire:submit="applyFilter" class="mb-5 p-4">
    <h5 class="mb-3 mb-2 font-bold">Filtres</h5>

    {{ $this->form }}

    <button type="submit">
        Submit
    </button>

</form>
<x-filament-actions::modals />


And the dd() with a selected value in the select field :
array:1 [▼ // app\Filament\Pages\StatisticsPage.php:120
  "sondage_id" => null
]
Solution
Did you add $this->form->fill() in the mount method?
Was this page helpful?