function FormWizardBase::submitForm

Same name in other branches
  1. 8.x-3.x src/Wizard/FormWizardBase.php \Drupal\ctools\Wizard\FormWizardBase::submitForm()

Overrides FormInterface::submitForm

File

src/Wizard/FormWizardBase.php, line 285

Class

FormWizardBase
The base class for all form wizard.

Namespace

Drupal\ctools\Wizard

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    // Only perform this logic if we're moving to the next page. This prevents
    // the loss of cached values on ajax submissions.
    if ((string) $form_state->getValue('op') == (string) $this->getNextOp()) {
        $cached_values = $form_state->getTemporaryValue('wizard');
        if ($form_state->hasValue('label')) {
            $cached_values['label'] = $form_state->getValue('label');
        }
        if ($form_state->hasValue('id')) {
            $cached_values['id'] = $form_state->getValue('id');
        }
        if (is_null($this->machine_name) && !empty($cached_values['id'])) {
            $this->machine_name = $cached_values['id'];
        }
        $this->getTempstore()
            ->set($this->getMachineName(), $cached_values);
        if (!$form_state->get('ajax')) {
            $form_state->setRedirect($this->getRouteName(), $this->getNextParameters($cached_values));
        }
    }
}