function WidgetBase::deleteAjax

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Field/WidgetBase.php \Drupal\Core\Field\WidgetBase::deleteAjax()

Ajax refresh callback for the "Remove" button.

This returns the new widget element content to replace the previous content made obsolete by the form submission.

Parameters

array $form: The form array to remove elements from.

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

File

core/lib/Drupal/Core/Field/WidgetBase.php, line 442

Class

WidgetBase
Base class for 'Field widget' plugin implementations.

Namespace

Drupal\Core\Field

Code

public static function deleteAjax(array &$form, FormStateInterface $form_state) {
    $button = $form_state->getTriggeringElement();
    return NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -3));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.