You are here

function field_group_field_group_pre_render in Field Group 8.3

Same name and namespace in other branches
  1. 8 field_group.module \field_group_field_group_pre_render()
  2. 7.2 field_group.module \field_group_field_group_pre_render()
  3. 7 field_group.module \field_group_field_group_pre_render()

Implements hook_field_group_pre_render().

Parameters

array $element: Group beïng rendered.

object $group: The Field group info.

$rendering_object: The entity / form beïng rendered

File

./field_group.module, line 464
Allows administrators to attach field groups.

Code

function field_group_field_group_pre_render(&$element, &$group, &$rendering_object) {

  // Add all field_group format types to the js settings.
  $element['#attached']['drupalSettings']['field_group'] = [
    $group->format_type => [
      'mode' => $group->mode,
      'context' => $group->context,
      'settings' => $group->format_settings,
    ],
  ];
  $element['#weight'] = $group->weight;

  // Call the pre render function for the format type.
  $manager = Drupal::service('plugin.manager.field_group.formatters');
  $plugin = $manager
    ->getInstance([
    'format_type' => $group->format_type,
    'configuration' => [
      'label' => $group->label,
      'settings' => $group->format_settings,
    ],
    'group' => $group,
  ]);
  if ($plugin) {
    $plugin
      ->preRender($element, $rendering_object);
  }
}