function FormWizardBase::previous

Same name in other branches
  1. 4.0.x src/Wizard/FormWizardBase.php \Drupal\ctools\Wizard\FormWizardBase::previous()

Overrides FormWizardInterface::previous

File

src/Wizard/FormWizardBase.php, line 329

Class

FormWizardBase
The base class for all form wizard.

Namespace

Drupal\ctools\Wizard

Code

public function previous(array &$form, FormStateInterface $form_state) {
    $cached_values = $form_state->getTemporaryValue('wizard');
    $prev_parameters = $this->getPreviousParameters($cached_values);
    // Redirect for non ajax forms.
    if (!$form_state->get('ajax')) {
        $form_state->setRedirect($this->getRouteName(), $prev_parameters);
    }
    else {
        // Switch step for ajax forms.
        if (!empty($prev_parameters['step'])) {
            $this->step = $prev_parameters['step'];
        }
    }
}