You are here

function FieldCollectionEmbedWidget::ajaxRemove in Field collection 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php \Drupal\field_collection\Plugin\Field\FieldWidget\FieldCollectionEmbedWidget::ajaxRemove()

Ajax callback to remove a field collection from a multi-valued field.

Parameters

array $form:

\Drupal\Core\Form\FormStateInterface $form_state:

Return value

\Drupal\Core\Ajax\AjaxResponse An AjaxResponse object.

See also

self::removeSubmit()

File

src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php, line 345

Class

FieldCollectionEmbedWidget
Plugin implementation of the 'field_collection_embed' widget.

Namespace

Drupal\field_collection\Plugin\Field\FieldWidget

Code

function ajaxRemove(array $form, FormStateInterface &$form_state) {

  // At this point, $this->removeSubmit() removed the element so we just need
  // to return the parent element.
  $button = $form_state
    ->getTriggeringElement();
  return NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -3));
}