© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•12mo ago•
4 replies
Arjen

$this->form->getState() empty

Hi, I've created a Filament page with the make command and I've placed a form inside the component. When I submit my form,
$this->form->getState()
$this->form->getState()
returns an empty array and I'm not sure why. The $data property however is filled correctly, and my validation also runs fine. Any idea what's wrong with my code? Or shouldn't I use
$this->form->getState()
$this->form->getState()
and just use
$this->data
$this->data
?

My file:
class VolunteerSettings extends Page implements HasForms
{
    use InteractsWithFormActions;
    use InteractsWithForms;

    protected static ?string $navigationIcon = 'heroicon-o-document-text';

    protected static string $view = 'filament.pages.volunteer-settings';

    protected static ?string $slug = 'vrijwilligervoorkeuren';

    protected static ?string $title = 'Vrijwilligervoorkeuren';

    public ?array $data = [];

    public function mount()
    {
        $this->form->fill();
    }

    public function form(Form $form): Form
    {
        return $form
            ->model(auth()->user())
            ->schema([
                Forms\Components\Section::make()
                    ->relationship('volunteerProfile')
                    ->schema([
                        'is_active' => Forms\Components\Toggle::make('is_active')
                            ->label('Actief profiel')
                            ->default(false)
                            ->live(),
                        // ...
                    ]),
            ])
            ->statePath('data');
    }

    public function getFormActions(): array
    {
        return [
            Actions\Action::make('submit')
                ->label('Opslaan')
                ->submit('submit'),
        ];
    }

    public function submit()
    {
        $data = $this->form->getState();
        dd($data, $this->data);
    }
}
class VolunteerSettings extends Page implements HasForms
{
    use InteractsWithFormActions;
    use InteractsWithForms;

    protected static ?string $navigationIcon = 'heroicon-o-document-text';

    protected static string $view = 'filament.pages.volunteer-settings';

    protected static ?string $slug = 'vrijwilligervoorkeuren';

    protected static ?string $title = 'Vrijwilligervoorkeuren';

    public ?array $data = [];

    public function mount()
    {
        $this->form->fill();
    }

    public function form(Form $form): Form
    {
        return $form
            ->model(auth()->user())
            ->schema([
                Forms\Components\Section::make()
                    ->relationship('volunteerProfile')
                    ->schema([
                        'is_active' => Forms\Components\Toggle::make('is_active')
                            ->label('Actief profiel')
                            ->default(false)
                            ->live(),
                        // ...
                    ]),
            ])
            ->statePath('data');
    }

    public function getFormActions(): array
    {
        return [
            Actions\Action::make('submit')
                ->label('Opslaan')
                ->submit('submit'),
        ];
    }

    public function submit()
    {
        $data = $this->form->getState();
        dd($data, $this->data);
    }
}
Solution
you should use
saveRelationships()
saveRelationships()

https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#passing-the-form-model-after-the-form-has-been-submitted
Adding a form to a Livewire component - Form Builder - Filament
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

$this->form->getState() without firing validations?
FilamentFFilament / ❓┊help
3y ago
Multiselect from->getState() empty values
FilamentFFilament / ❓┊help
3y ago
Issue with $this->form->getState() for Previewing Resume
FilamentFFilament / ❓┊help
2y ago
How to get $data from $this->form->getState() without triggering validations?
FilamentFFilament / ❓┊help
3y ago