how to perform some stuff before dispatching an event in action
public function clearAction(): Action
{
return Action::make('clear')
->size(ActionSize::Large)
->dispatch('clear-form');
} this action is clearing localstorage but i also want to clear form data along with this, for that i want to do this $this->form->fill(); can anyone please help me where i should use this ?
2 Replies
did you try ->action() and call $this->form->fill(); and $this->dispatch in it ?
hi @David Vincent , thanks for replying i have not tried what you have recommended instead i am doing this
#[On('clear-form')]
public function clearFormFileds()
{
$this->form->fill();
}
i have generated event listener and put that $this->form->fill(); inside and it is working fine, can you please let me know is it correct way or is it good practice ?