You are here

function paragraphs_frontend_ui_preprocess_field in Paragraphs frontend ui 8.2

Same name and namespace in other branches
  1. 8 paragraphs_frontend_ui.module \paragraphs_frontend_ui_preprocess_field()

Implements hook_preprocess_HOOK().

Using hook_preprocess_field().

File

./paragraphs_frontend_ui.module, line 143
Provides common hooks and alterations for paragraphs_frontend_ui module.

Code

function paragraphs_frontend_ui_preprocess_field(&$vars) {
  if (empty($vars['field_type']) || $vars['field_type'] !== 'entity_reference_revisions') {
    return;
  }
  if (Drupal::currentUser()
    ->isAuthenticated()) {
    $vars['attributes']['data-paragraphs-frontend-ui'] = $vars['field_name'] . '-' . $vars['element']['#object']
      ->id();
  }
}