public function SlideBaseForm::removeCallback in Drupal Slider 8
Same name and namespace in other branches
- 8.2 src/Form/SlideBaseForm.php \Drupal\drupal_slider\Form\SlideBaseForm::removeCallback()
Submit handler for the "remove one" button.
Decrements the max counter and causes a form rebuild.
File
- src/
Form/ SlideBaseForm.php, line 131
Class
- SlideBaseForm
- Class SlideBaseForm.
Namespace
Drupal\drupal_slider\FormCode
public function removeCallback(array &$form, FormStateInterface $form_state) {
$name_field = $form_state
->get('num_names');
if ($name_field > 1) {
$remove_button = $name_field - 1;
$form_state
->set('num_names', $remove_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();
}