You are here

function hook_field_group_pre_render in Field Group 8.3

Same name and namespace in other branches
  1. 7.2 field_group.api.php \hook_field_group_pre_render()
  2. 7 field_group.api.php \hook_field_group_pre_render()

Pre render the build of the field group element.

Parameters

array $element: Group being rendered.

object $group: The Field group info.

object $rendering_object: The entity / form being rendered.

1 function implements hook_field_group_pre_render()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_group_field_group_pre_render in ./field_group.module
Implements hook_field_group_pre_render().
1 invocation of hook_field_group_pre_render()
field_group_pre_render in ./field_group.module
Function to pre render the field group element.

File

./field_group.api.php, line 25
Hooks for the field_group module.

Code

function hook_field_group_pre_render(array &$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,
  ]);
  $plugin
    ->preRender($element, $rendering_object);
}