You are here

function paragraphs_ee_field_widget_form_alter in Paragraphs Editor Enhancements 8

Implements hook_field_widget_form_alter().

File

./paragraphs_ee.module, line 59
Main functions for "Paragraphs Editor Enhancements" module.

Code

function paragraphs_ee_field_widget_form_alter(&$element, FormStateInterface &$form_state, $context) {
  if (!$context['widget'] instanceof ParagraphsWidget) {
    return;
  }

  // Add custom library.
  $element['#attached']['library'][] = 'paragraphs_ee/paragraphs_ee.paragraphs';
  if (empty($element['#attached']['drupalSettings']['paragraphs_features'])) {

    // If the widget is not configured to use one of the features provided by
    // the module, this would not exist and cause an error.
    $element['#attached']['drupalSettings']['paragraphs_features'] = [];
  }
}