public function SocialLinkWidget::ajaxRemove in Social Link Field 8
Ajax callback to remove a field collection from a multi-valued field.
Parameters
array $form: The form structure where widgets are being attached to.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Ajax\AjaxResponse An AjaxResponse object.
File
- src/
Plugin/ Field/ FieldWidget/ SocialLinkWidget.php, line 346
Class
- SocialLinkWidget
- Plugin implementation of the 'open_hours' widget.
Namespace
Drupal\social_link_field\Plugin\Field\FieldWidgetCode
public function ajaxRemove(array $form, FormStateInterface &$form_state) {
$button = $form_state
->getTriggeringElement();
$parent = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -3));
return $parent;
}