You are here

function field_group_attach_groups in Field Group 7

Same name and namespace in other branches
  1. 8.3 field_group.module \field_group_attach_groups()
  2. 8 field_group.module \field_group_attach_groups()
  3. 7.2 field_group.module \field_group_attach_groups()

Attach groups to the (form) build.

Parameters

Array $element: The part of the form.

String $view_mode: The mode for the build.

Array $form_state: The optional form state when in view_mode = form context.

2 calls to field_group_attach_groups()
field_group_field_attach_form in ./field_group.module
Implements hook_field_attach_form().
field_group_field_attach_view_alter in ./field_group.module
Implements hook_field_attach_view_alter().

File

./field_group.module, line 1919
Fieldgroup module.

Code

function field_group_attach_groups(&$element, $view_mode, $form_state = array()) {
  $entity_type = $element['#entity_type'];
  $bundle = $element['#bundle'];
  $element['#groups'] = field_group_info_groups($entity_type, $bundle, $view_mode);
  $element['#fieldgroups'] = $element['#groups'];

  // Create a lookup array.
  $group_children = array();
  foreach ($element['#groups'] as $group_name => $group) {
    if (!empty($group->children)) {
      foreach ($group->children as $child) {
        $group_children[$child] = $group_name;
      }
    }
  }
  $element['#group_children'] = $group_children;
}