You are here

function field_group_pre_render_prepare in Field Group 7.2

Same name and namespace in other branches
  1. 7 field_group.module \field_group_pre_render_prepare()

Helper function to prepare basic variables needed for most formatters.

Called in field_group_field_group_pre_render(), but can also be called in other implementations of hook_field_group_pre_render().

1 call to field_group_pre_render_prepare()
field_group_field_group_pre_render in ./field_group.module
Implements hook_field_group_pre_render().

File

./field_group.module, line 579
Fieldgroup module.

Code

function field_group_pre_render_prepare(&$group) {

  // Prepare extra classes.
  $group->classes = array(
    'field-group-' . $group->format_type,
    str_replace('_', '-', $group->group_name),
  );
  if (isset($group->format_settings['formatter'])) {
    $group->collapsible = in_array($group->format_settings['formatter'], array(
      'collapsible',
      'collapsed',
    ));

    // Open or closed horizontal or vertical tabs will be collapsible by default.
    if ($group->format_type == 'tab' || $group->format_type == 'htab') {
      $group->collapsible = TRUE;
    }
    $group->collapsed = in_array($group->format_settings['formatter'], array(
      'collapsed',
      'closed',
    ));
    if ($group->collapsible) {
      $group->classes[] = 'collapsible';
      if ($group->collapsed) {
        $group->classes[] = 'collapsed';
      }
    }
  }

  // Add a required-fields class to trigger the js.
  if (isset($group->format_settings['instance_settings']) && !empty($group->format_settings['instance_settings']['required_fields'])) {
    $group->classes[] = 'required-fields';
  }
  $group->classes = implode(' ', $group->classes);
  if (isset($group->format_settings['instance_settings'], $group->format_settings['instance_settings']['classes'])) {
    $group->classes .= ' ' . check_plain($group->format_settings['instance_settings']['classes']);
  }
  $group->description = isset($group->format_settings['instance_settings']['description']) ? filter_xss_admin($group->format_settings['instance_settings']['description']) : '';
}