Get old state

I have two components in a Form. I can copy the value over from one component to the other. Now I want to have an action to undo this.
I tried the following:

->hintAction(
  Action::make('undoJobTitle')
      ->label('Herstel oude waarde')
      ->icon('heroicon-m-clipboard')
      ->action(function ($component, $livewire, $state, $set) {
  
          dd($component->getLivewire()->getOldFormState($component->getStatePath()));
  
      })


Also, this:

dd($component->getOldState());


Both return
null
after I changed the value of the field. Not sure if I'm doing it right. Maybe I have to save the form first, but that is not what I want.
Any ideas?
Was this page helpful?