fieldset_helper.module

Version 1.1.2.5 (checked in on 2009/04/23 at 20:43:32 by jrockowitz)

Saves the collapsed state of a Drupal collapsible fieldset.

Besided saving the state of collapsible fieldsets this module improves the usability of the main module page (admin/build/modules) by adding expand and collapse all links to top of the page.

Notes:

  • Fieldset ids are generated based on the FAPI form's associated array keys or the id is generated from the fieldset's title.
  • All generated fieldset ids will be pre-pended with 'fieldset-'.
  • All collaspible fieldsets should be generate using theme('fieldset', $element); but you can also use static html.
  • This module attempts to override some fieldset related theme functions. These functions include 'phptemplate_fieldset', 'phptemplate_fieldgroup_fieldset', and 'theme_system_modules'.
Fieldset helper state manager:

  • The 'state manager' stores the state of a collapsible fieldset in a session coooke.
  • The state manager dramatically reduces the cookie's size, by converting the fieldset's element_id combined with the path to an auto incremented numeric id.
  • The state management is controlled by the fieldset_helper_state_manager php functions and the FieldsetHelperStateManager JavaScript object which isolates the API so that it can copied, renamed, and re-used.
Questions/Issues

  • Should the fieldset state cookie persist across multiple browser session?
I personally say no but this could useful for admins.

  • Currently every collapsible fieldset's state is being saved should this be something that developers can control via admin settings and/or a fieldset properties?
I think the functionality of any reusable widget should the same, whenever possible, across all instances. So, I don't think this is something that should be customizable on a per instance basis.

Related discussions

Similar modules

Functions

NameDescription
fieldset_helper_alter_theme_fieldsetTheme related function that is used by the phptemplate_fieldset() function (in fieldset_helper.theme.inc) used to alter the fieldset so that its collapsible state can be saved.
fieldset_helper_alter_theme_system_modulesTheme related function used by the included phptemplate_theme_system() to prepend 'Expand all | Collapse all' to the system modules page.
fieldset_helper_form_alterImplementation of hook_form_alter().
fieldset_helper_menuImplementation of hook_menu().
fieldset_helper_permImplementation of hook_perm().
fieldset_helper_state_manager_clear_lookup_idsClear all the store lookup id for every form.
fieldset_helper_state_manager_get_cookie_statesGet an associated array for lookup id and the element's state (1 or 0) from $_COOKIE['fieldset_helper_state_manager'].
fieldset_helper_state_manager_get_lookup_idGet the lookup id for the $element_id in the current path.
fieldset_helper_state_manager_get_stateGet fieldset's collapsed state.
fieldset_helper_themeImplementation of hook_theme().
theme_fieldset_helper_toggle_allTheme 'Expand all | Collapse all' links that toggle a page or selected fieldsets state.
_fieldset_helper_add_jsAdds 'fieldset_helper.js' and related settings to a page only once.
_fieldset_helper_format_idFormats any string as fieldset id prepended with 'fieldset-'.
_fieldset_helper_set_collapsible_fieldset_idsSet collapsible fieldsets id based on the associated array keys.