public function ajaxLeadershipCallback(array $form, FormStateInterface $form_state) {
    $triggering_element = $form_state->getTriggeringElement();
    if ($triggering_element['#name'] == 'previous') {
      $form_state->set('page', $form_state->get('page') - 1);
    }
    elseif ($triggering_element['#name'] == 'next') {
      $form_state->set('page', $form_state->get('page') + 1);
    }
    else {
      $form_state->set('page', 0);
    }
    $new_form = $this->formBuilder->rebuildForm($this->getFormId(), $form_state, $form);
    return $new_form;
  }
public function ajaxLeadershipCallback(array $form, FormStateInterface $form_state) {
    $triggering_element = $form_state->getTriggeringElement();
    if ($triggering_element['#name'] == 'previous') {
      $form_state->set('page', $form_state->get('page') - 1);
    }
    elseif ($triggering_element['#name'] == 'next') {
      $form_state->set('page', $form_state->get('page') + 1);
    }
    else {
      $form_state->set('page', 0);
    }
    $new_form = $this->formBuilder->rebuildForm($this->getFormId(), $form_state, $form);
    return $new_form;
  }
public function ajaxLeadershipCallback ( array $ form , FormStateInterface $ form_state ) { $ triggering_element = $ form_state -> getTriggeringElement ( ) ; if ( $ triggering_element [ '#name' ] == 'previous' ) { $ form_state -> set ( 'page' , $ form_state -> get ( 'page' ) - 1 ) ; } elseif ( $ triggering_element [ '#name' ] == 'next' ) { $ form_state -> set ( 'page' , $ form_state -> get ( 'page' ) + 1 ) ; } else { $ form_state -> set ( 'page' , 0 ) ; } $ new_form = $ this -> formBuilder -> rebuildForm ( $ this -> getFormId ( ) , $ form_state , $ form ) ; return $ new_form ; }
AJAX Callback for the whole form.

@param array $form
An associative array containing the structure of the form.
@param \Drupal\Core\Form\FormStateInterface $form_state
The current state of the form.

@return array
The portion of the render structure that will replaced.
AJAX Callback for the whole form .