You are here

public function EntityReferenceLayoutWidget::removeItemSubmit in Entity Reference with Layout 8

Form submit handler - opens confirm removal form for an item.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Plugin/Field/FieldWidget/EntityReferenceLayoutWidget.php, line 1070

Class

EntityReferenceLayoutWidget
Entity Reference with Layout field widget.

Namespace

Drupal\entity_reference_layout\Plugin\Field\FieldWidget

Code

public function removeItemSubmit(array $form, FormStateInterface $form_state) {
  $element = $form_state
    ->getTriggeringElement();
  $parents = $element['#element_parents'];
  $delta = $element['#delta'];
  $widget_state = static::getWidgetState($parents, $this->fieldName, $form_state);
  $widget_state['remove_item'] = $delta;
  static::setWidgetState($parents, $this->fieldName, $form_state, $widget_state);
  $form_state
    ->setRebuild();
}