function theme_ds_multigroup_fieldset in Display Suite 6.2
Same name and namespace in other branches
- 6.3 theme/theme.inc \theme_ds_multigroup_fieldset()
Theme a multigroup as a collection of fieldsets.
Parameters
string $group: The multigroup to theme.
Return value
bool | string A string representing the rendered fieldset, or FALSE if not content is rendered.
1 string reference to 'theme_ds_multigroup_fieldset'
- _ds_theme in includes/
ds.registry.inc - Return theme functions.
File
- theme/
theme.inc, line 253 - 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) {
if (isset($row['content']) && !empty($row['content'])) {
// 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;
}