1 field_group.api.php hook_field_group_build_pre_render_alter(array &$element)

Implements hook_field_group_build_pre_render_alter().

Last resort where you can alter things. It is expected that when you need this function, you have most likely a very custom case or it is a fix that can be put in field_group core.

Parameters

array $element: Elements by address.

Related topics

File

core/modules/field_group/field_group.api.php, line 299
Hooks provided by the Field Group module.

Code

function hook_field_group_build_pre_render_alter(array &$element) {

  // Prepare variables.
  $display = isset($element['#view_mode']);
  $groups = array_keys($element['#groups']);

  // Example from field_group itself to unset empty elements.
  if ($display) {
    field_group_remove_empty_display_groups($element, $groups);
  }

  // You might include additional javascript files and stylesheets.
  $element['#attached']['js'][] = backdrop_get_path('module', 'field_group') . '/js/field_group.js';
  $element['#attached']['css'][] = backdrop_get_path('module', 'field_group') . '/css/field_group.css';

}