You are here

function paragraphs_features_field_widget_multivalue_form_alter in Paragraphs Features 2.x

Same name and namespace in other branches
  1. 8 paragraphs_features.module \paragraphs_features_field_widget_multivalue_form_alter()

Implements hook_field_widget_multivalue_form_alter().

File

./paragraphs_features.module, line 18
Contains hooks for Paragraphs Feature module.

Code

function paragraphs_features_field_widget_multivalue_form_alter(array &$elements, FormStateInterface $form_state, array $context) {

  /** @var \Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget $widget */
  $widget = $context['widget'];
  if (!$widget instanceof ParagraphsWidget) {
    return;
  }

  // For compatibility with Drag & Drop in Paragraphs.
  if (!empty($elements['#field_name'])) {
    $fieldWrapperId = ParagraphsFeatures::getWrapperId($context['form']['#parents'], $elements['#field_name']);
    ParagraphsFeatures::registerFormWidgetFeatures($elements, $widget, $fieldWrapperId);
  }
}