You are here

public function SlideBaseForm::addOne in Drupal Slider 8

Same name and namespace in other branches
  1. 8.2 src/Form/SlideBaseForm.php \Drupal\drupal_slider\Form\SlideBaseForm::addOne()

Submit handler for the "add-one-more" button.

Increments the max counter and causes a rebuild.

File

src/Form/SlideBaseForm.php, line 119

Class

SlideBaseForm
Class SlideBaseForm.

Namespace

Drupal\drupal_slider\Form

Code

public function addOne(array &$form, FormStateInterface $form_state) {
  $name_field = $form_state
    ->get('num_names');
  $add_button = $name_field + 1;
  $form_state
    ->set('num_names', $add_button);
  $form_state
    ->setRebuild();
}