You are here

function theme_ds_multigroup_fieldset in Display Suite 6.3

Same name and namespace in other branches
  1. 6.2 theme/theme.inc \theme_ds_multigroup_fieldset()

Theme a multigroup as a collection of fieldsets.

Parameters

string $group : The multigroup to theme.

1 string reference to 'theme_ds_multigroup_fieldset'
_ds_theme in includes/ds.registry.inc
Return theme functions.

File

theme/theme.inc, line 241
Theming functions for ds.

Code

function theme_ds_multigroup_fieldset($group) {
  $collapsible = FALSE;
  $class = NULL;
  $variation = array_pop(explode('_', $group['theme']));
  switch ($variation) {
    case 'collapsible':
      $collapsible = TRUE;
      $class = ' collapsible';
      break;
    case 'collapsed':
      $collapsible = TRUE;
      $class = ' collapsible collapsed';
      break;
    default:
      break;
  }

  // Add js.
  if ($collapsible == TRUE) {
    drupal_add_js('misc/collapse.js');
  }

  // Build content by iterating over subgroups
  $content = '';
  foreach ($group['rows'] as $row) {

    // Set a legend if a field title exists
    $legend = NULL;
    if (!empty($row['title']) || $collapsible == TRUE) {
      if (empty($row['title'])) {

        // @todo - what goes here when no value is present?
        $row['title'] = 'open/close';
      }
      $legend = '<legend>' . $row['title'] . '</legend>';
    }
    $content .= '<fieldset class="group ' . $row['class'] . $class . '">' . $legend . $row['content'] . '</fieldset>';
  }
  return $content;
}