validate() vs getState()

Hi guys ! I'm using a custom Form inside a Livewire component and I need to understand the difference between validate() and getState(). Here is my code :

public function create(): void
{
    $data = $this->form->validate(); // I get validated data, without hidden fields such as `has_blabla`
    $dataBis = $this->form->getState(); // I get validated data, with hidden fields such as `has_blabla`, is it normal ?
}


I'm reusing form fields across multiple forms and some fields needs to be hidden (for the user + in the data), like this one :

Components\TextInput::make('has_blabla')
    ->label('blabla')
    ->required()
    ->visible(fn (): bool => $this->formType === FormTypeEnum::WITNESS),
Was this page helpful?