You are here

public function MultistepForm::fapiExampleMultistepFormNextSubmit in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 form_api_example/src/Form/MultistepForm.php \Drupal\form_api_example\Form\MultistepForm::fapiExampleMultistepFormNextSubmit()

Provides custom submission handler for page 1.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

modules/form_api_example/src/Form/MultistepForm.php, line 123

Class

MultistepForm
Provides a form with two steps.

Namespace

Drupal\form_api_example\Form

Code

public function fapiExampleMultistepFormNextSubmit(array &$form, FormStateInterface $form_state) {
  $form_state
    ->set('page_values', [
    // Keep only first step values to minimize stored data.
    'first_name' => $form_state
      ->getValue('first_name'),
    'last_name' => $form_state
      ->getValue('last_name'),
    'birth_year' => $form_state
      ->getValue('birth_year'),
  ])
    ->set('page_num', 2)
    ->setRebuild(TRUE);
}