Skip to content

Commit

Permalink
fix: fixed back button causing issues when using default html valid…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
gustavs-gutmanis committed Sep 28, 2022
1 parent 4852f49 commit a29da8c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Solspace\Freeform\Events\Forms\HandleRequestEvent;
use Solspace\Freeform\Events\Forms\ResetEvent;
use Solspace\Freeform\Events\Forms\ValidationEvent;
use Solspace\Freeform\Fields\SubmitField;
use Solspace\Freeform\Form\Bags\PropertyBag;
use Solspace\Freeform\Freeform;
use Solspace\Freeform\Library\Composer\Components\Form;
Expand All @@ -15,6 +14,8 @@

class PageContext
{
public const KEY_ACTION_BACK = 'back';

public function __construct()
{
Event::on(Form::class, Form::EVENT_BEFORE_VALIDATE, [$this, 'onValidate']);
Expand All @@ -41,7 +42,7 @@ public function handleNavigateBack(HandleRequestEvent $event)
return;
}

$shouldWalkBack = null !== RequestHelper::post(SubmitField::PREVIOUS_PAGE_INPUT_NAME);
$shouldWalkBack = self::KEY_ACTION_BACK === RequestHelper::post(Form::ACTION_KEY);
if ($shouldWalkBack) {
$pageHistory = $bag->get(Form::PROPERTY_PAGE_HISTORY, []);
$index = array_pop($pageHistory) ?? 0;
Expand Down

0 comments on commit a29da8c

Please sign in to comment.