function FormWizardBase::populateCachedValues

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

Form validation handler that populates the cached values from tempstore.

Temporary values are only available for a single page load so form submission will lose all the values. This was we reload and provide them to the validate and submit process.

Parameters

array $form: Drupal form array.

\Drupal\Core\Form\FormStateInterface $form_state: The initial form state before validation or submission of the steps.

Overrides FormWizardInterface::populateCachedValues

File

src/Wizard/FormWizardBase.php, line 309

Class

FormWizardBase
The base class for all form wizard.

Namespace

Drupal\ctools\Wizard

Code

public function populateCachedValues(array &$form, FormStateInterface $form_state) {
  $cached_values = $this->getTempstore()
    ->get($this->getMachineName());
  if (!$cached_values) {
    $cached_values = $form_state->getTemporaryValue('wizard');
    if (!$cached_values) {
      $cached_values = $this->initValues();
      $form_state->setTemporaryValue('wizard', $cached_values);
    }
  }
}