From 71568ee8a1666a60ef0ceece34b7cc6ca81af8c7 Mon Sep 17 00:00:00 2001 From: Lucas Yang Date: Sun, 8 Sep 2024 23:04:13 +0800 Subject: [PATCH] Should back to previous step without validation --- src/Wizardable.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Wizardable.php b/src/Wizardable.php index e96c8b0..eff5d3c 100644 --- a/src/Wizardable.php +++ b/src/Wizardable.php @@ -101,7 +101,16 @@ public function store(Request $request, string $step) $step = $this->getWizardStep($request, $step); - if ($step->skip() && $request->query('_trigger') === 'skip') { + // If trigger from 'back', set this step index and redirect to prev step. + if ($request->query('_trigger') === 'back' && $this->beforeBackWizardStep($request)) { + if ($this->wizard()->option('cache')) { + $step->cacheProgress($request); + } + + $prevStep = $this->wizard()->stepRepo()->prev(); + + return $this->setThisStepAndRedirectTo($request, $prevStep); + } elseif ($step->skip() && $request->query('_trigger') === 'skip') { if ($this->wizard()->option('cache')) { $step->cacheProgress($request); } @@ -128,13 +137,6 @@ public function store(Request $request, string $step) if ($redirectTo = $this->wizardStepSaved($request, $step)) { return $redirectTo; } - - // If trigger from 'back', set this step index and redirect to prev step. - if ($request->query('_trigger') === 'back' && $this->beforeBackWizardStep($request)) { - $prevStep = $this->wizard()->stepRepo()->prev(); - - return $this->setThisStepAndRedirectTo($request, $prevStep); - } } if ($this->isLastStep()) {