You are here

function hook_field_group_build_pre_render_alter in Field Group 7

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

Implements hook_field_group_build_pre_render_alter().

Function that fungates as 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 $elements by address.:

1 function implements hook_field_group_build_pre_render_alter()

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_build_pre_render_alter in ./field_group.module
Implements hook_field_group_build_pre_render_alter().

File

./field_group.api.php, line 288
Hooks provided by the Field Group module.

Code

function hook_field_group_build_pre_render_alter(&$element) {

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

  // Example from field_group itself to unset empty elements.
  if ($display) {
    foreach (element_children($element) as $name) {
      if (in_array($name, $groups)) {
        if (field_group_field_group_is_empty($element[$name], $groups)) {
          unset($element[$name]);
        }
      }
    }
  }

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