public function SlideGroupBaseForm::addOne in Drupal Slider 8
Same name and namespace in other branches
- 8.2 src/Form/SlideGroupBaseForm.php \Drupal\drupal_slider\Form\SlideGroupBaseForm::addOne()
Submit handler for the "add-one-more" button.
Increments the max counter and causes a rebuild.
File
- src/
Form/ SlideGroupBaseForm.php, line 121
Class
- SlideGroupBaseForm
- Class SlideGroupBaseForm.
Namespace
Drupal\drupal_slider\FormCode
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);
// Since our buildForm() method relies on the value of 'num_names' to
// generate 'name' form elements, we have to tell the form to rebuild. If we
// don't do this, the form builder will not call buildForm().
$form_state
->setRebuild();
}