You are here

function simple_multistep_form_alter in Simple multi step form 8.x

Same name and namespace in other branches
  1. 8 simple_multistep.module \simple_multistep_form_alter()

Implements hook_form_alter().

File

./simple_multistep.module, line 14
Contains simple_multistep.module.

Code

function simple_multistep_form_alter(&$form, FormStateInterface &$form_state) {

  // Check if form using form group multi step field.
  if (_check_form_multistep($form)) {

    /** @var \Drupal\simple_multistep\MultistepController $multiStep */
    if ($multiStep = $form_state
      ->get('multistep_controller')) {
      $multiStep
        ->updateStepInfo();
    }
    else {
      $multiStep = new MultistepController($form, $form_state);
    }
    $multiStep
      ->rebuildForm($form);
    $form_state
      ->set('multistep_controller', $multiStep);

    // Attach style library.
    $form['#attached']['library'][] = 'simple_multistep/simple_multistep';
  }
}