public static WidgetBase::addMoreSubmit(array $form, FormStateInterface $form_state)
Submission handler for the "Add another item" button.
File
- core/lib/Drupal/Core/Field/WidgetBase.php, line 269
Class
- WidgetBase
- Base class for 'Field widget' plugin implementations.
Namespace
Drupal\Core\Field
Code
public static function addMoreSubmit(array $form, FormStateInterface $form_state) { $button = $form_state->getTriggeringElement(); // Go one level up in the form, to the widgets container. $element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1)); $field_name = $element['#field_name']; $parents = $element['#field_parents']; // Increment the items count. $field_state = static::getWidgetState($parents, $field_name, $form_state); $field_state['items_count']++; static::setWidgetState($parents, $field_name, $form_state, $field_state); $form_state->setRebuild(); }
Please login to continue.