You are here

function field_group_field_group_pre_render in Field Group 7.2

Same name and namespace in other branches
  1. 8.3 field_group.module \field_group_field_group_pre_render()
  2. 8 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 $elements by address.:

Object $group The Field group info.:

File

./field_group.module, line 618
Fieldgroup module.

Code

function field_group_field_group_pre_render(&$element, &$group, &$form) {
  field_group_pre_render_prepare($group);
  $view_mode = isset($form['#view_mode']) ? $form['#view_mode'] : 'form';

  // Add all field_group format types to the js settings.
  $form['#attached']['js'][] = array(
    'data' => array(
      'field_group' => array(
        $group->format_type => $view_mode,
      ),
    ),
    'type' => 'setting',
  );
  $form['#attached']['js'][] = 'misc/form.js';
  $form['#attached']['js'][] = 'misc/collapse.js';
  if (isset($group->format_settings['instance_settings']['id']) && !empty($group->format_settings['instance_settings']['id'])) {
    $element['#id'] = $group->format_settings['instance_settings']['id'];
  }
  else {
    $element['#id'] = $form['#entity_type'] . '_' . $form['#bundle'] . '_' . $view_mode . '_' . $group->group_name;
  }
  $element['#weight'] = $group->weight;

  // Call the pre render function for the format type.
  $function = "field_group_pre_render_" . str_replace("-", "_", $group->format_type);
  if (function_exists($function)) {
    $function($element, $group, $form);
  }
}