You are here

public function AmswapConfigForm::addPair in Admin Menu Swap 8

File

src/Form/AmswapConfigForm.php, line 138

Class

AmswapConfigForm
Class AmswapConfigForm.

Namespace

Drupal\amswap\Form

Code

public function addPair(array $form, FormStateInterface &$form_state) {

  // Get the current number of pairs, or 1 if not provided.
  $num_pairs = $form_state
    ->get('num_pairs');
  $num_pairs = $num_pairs ? $num_pairs : 1;

  // Add 1 to the number of role-menu pairs that should be displayed.
  $form_state
    ->set('num_pairs', $num_pairs + 1);

  // Set the form to be rebuilt.
  $form_state
    ->setRebuild(TRUE);
}