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
Vp2mo 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
TegarJKOP2mo ago
thank you, have you ever done something like this before?
Vp
Vp2mo ago
No sorry
TegarJK
TegarJKOP2mo ago
okay no worries
lutek
lutek2mo 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
TegarJKOP2mo ago
thank you, 1 question , is this code in createResource class or resource class? and does it work when i refresh the browser?
lutek
lutek2mo 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