function hook_field_group_pre_render in Field Group 7
Same name and namespace in other branches
- 8.3 field_group.api.php \hook_field_group_pre_render()
- 7.2 field_group.api.php \hook_field_group_pre_render()
Implements hook_field_group_pre_render().
This function gives you the oppertunity to create the given wrapper element that can contain the fields. In the example beneath, some variables are prepared and used when building the actual wrapper element. All elements in drupal fapi can be used.
Note that at this point, the field group has no notion of the fields in it.
There is also an alternative way of handling this. The default implementation within field_group calls "field_group_pre_render_<format_type>".
Parameters
Array $elements by address.:
Object $group The Field group info.:
See also
field_group_pre_render_fieldset.
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 223 - Hooks provided by the Field Group module.
Code
function hook_field_group_pre_render(&$element, $group, &$form) {
// You can prepare some variables to use in the logic.
$view_mode = isset($form['#view_mode']) ? $form['#view_mode'] : 'form';
$id = $form['#entity_type'] . '_' . $form['#bundle'] . '_' . $view_mode . '_' . $group->group_name;
// Each formatter type can have whole different set of element properties.
switch ($group->format_type) {
// Normal or collapsible div.
case 'div':
$effect = isset($group->format_settings['instance_settings']['effect']) ? $group->format_settings['instance_settings']['effect'] : 'none';
$speed = isset($group->format_settings['instance_settings']['speed']) ? $group->format_settings['instance_settings']['speed'] : 'none';
$add = array(
'#type' => 'markup',
'#weight' => $group->weight,
'#id' => $id,
);
$classes .= " speed-{$speed} effect-{$effect}";
if ($group->format_settings['formatter'] != 'open') {
$add['#prefix'] = '<div class="field-group-format ' . $classes . '">
<span class="field-group-format-toggler">' . check_plain(t($group->label)) . '</span>
<div class="field-group-format-wrapper" style="display: none;">';
$add['#suffix'] = '</div></div>';
}
else {
$add['#prefix'] = '<div class="field-group-format ' . $group->group_name . ' ' . $classes . '">';
$add['#suffix'] = '</div>';
}
if (!empty($description)) {
$add['#prefix'] .= '<div class="description">' . $description . '</div>';
}
$element += $add;
if ($effect == 'blind') {
drupal_add_library('system', 'effects.blind');
}
break;
break;
}
}