You are here

function user_relationships_ui_account_fieldset_remove_if_empty in User Relationships 7

Hides the settings fieldset if there are no options to be displayed.

1 string reference to 'user_relationships_ui_account_fieldset_remove_if_empty'
user_relationships_ui_form_alter in user_relationships_ui/user_relationships_ui.module
Implements hook_form_alter().

File

user_relationships_ui/user_relationships_ui.module, line 556
UI components of user_relationships @author Jeff Smick (creator) @author Alex Karshakevich (maintainer) http://drupal.org/user/183217 @author Darren Ferguson (contributor) http://drupal.org/user/70179

Code

function user_relationships_ui_account_fieldset_remove_if_empty($element) {

  // Go through all child elements, if any of them is visible, do not hide.
  // If no elements exist or none are accessible, hide this element.
  foreach (element_children($element) as $key) {
    if (!isset($element[$key]['#access']) || $element[$key]['#access']) {
      return $element;
    }
  }
  $element['#access'] = FALSE;
  return $element;
}