function fieldset_helper_alter_theme_fieldset in Fieldset helper 6
Same name and namespace in other branches
- 6.2 fieldset_helper.theme.inc \fieldset_helper_alter_theme_fieldset()
Theme related function that is used by the phptemplate_fieldset() function (in fieldset_helper.theme.inc) to alter the fieldset so that its collapsible state can be saved.
If an enabled theme overrides fieldset theme then those theme functions and/or files should call the below function.
Parameters
$element: A FAPI fieldset element.
Return value
The fieldset element. Collapsible fieldsets will have a unique id and a default collapsed state set from the user's 'fieldset_helper' cookie.
3 calls to fieldset_helper_alter_theme_fieldset()
- FieldsetHelperTestCase::testFieldsetHelperAlterThemeFieldset in ./
fieldset_helper.test - Test alter fieldset element which can also create fieldset ids for modules like CCK.
- phptemplate_fieldgroup_fieldset in ./
fieldset_helper.theme.inc - Overide CCK's theme_fieldgroup_fieldset using phptemplate.
- phptemplate_fieldset in ./
fieldset_helper.theme.inc - Overide theme_fieldset using phptemplate.
File
- ./
fieldset_helper.module, line 281 - Saves the collapsed state of a Drupal collapsible fieldset.
Code
function fieldset_helper_alter_theme_fieldset($element) {
// Exit if fieldsets state is not save or the fieldset is not collapsible.
if (!user_access('save fieldset state') || empty($element['#collapsible'])) {
return $element;
}
// Add js
fieldset_helper_add_js();
// Set id for fieldsets without them.
if (empty($element['#attributes']['id'])) {
// Fieldsets without titles can not have an id automatically generated.
if (empty($element['#title'])) {
return $element;
}
$element['#attributes']['id'] = _fieldset_helper_format_id('fieldset-' . $element['#title']);
}
// Set fieldset's default collapsed state
$element['#collapsed'] = isset($element['#collapsed']) ? $element['#collapsed'] : FALSE;
// Set fieldset state
$element['#collapsed'] = fieldset_helper_state_manager_get_state($element['#attributes']['id'], $element['#collapsed']);
return $element;
}