How to make wizard keep its input data after accidental refresh

By default if users accidentally refresh their browser, the wizard progress automaticly reset all input, How do i make it keep its inputted data? i dont want to frustate my users since the wizard have alot of steps
7 Replies
Vp
Vp4d ago
Not really sure but you can save in local storage or smt using afterValidation https://filamentphp.com/docs/3.x/forms/layout/wizard#step-lifecycle-hooks
TegarJK
TegarJK4d ago
thank you, have you ever done something like this before?
Vp
Vp4d ago
No sorry
TegarJK
TegarJK4d ago
okay no worries
lutek
lutek4d ago
I store all data in the database (have multistep order), after each step:
])->afterValidation(function (Get $get) {
$this->cart->step = 2;
UpdateCart::run($this->cart);
});
])->afterValidation(function (Get $get) {
$this->cart->step = 2;
UpdateCart::run($this->cart);
});
TegarJK
TegarJK4d ago
thank you, 1 question , is this code in createResource class or resource class? and does it work when i refresh the browser?
lutek
lutek4d ago
this is custom page and i mounting cart data see https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component or see "class EditRecord extends Page". Yes it works when i refresh the browser even remember last step
->startOnStep(fn (): int => $this->cart->step ?? 1)
->startOnStep(fn (): int => $this->cart->step ?? 1)
Want results from more Discord servers?
Add your server