You are here

function field_group_attach_groups in Field Group 8

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

Attach groups to the (form) build.

Parameters

Array $element: The part of the form. @param Array $context The contextual information.

3 calls to field_group_attach_groups()
field_group_entity_view_alter in ./field_group.module
Implements hook_entity_view_alter().
field_group_form_alter in ./field_group.module
Implements hook_form_alter().
field_group_inline_entity_form_entity_form_alter in ./field_group.module
Implements hook_inline_entity_form_entity_form_alter().

File

./field_group.module, line 342
Allows administrators to attach custom fields to fieldable types.

Code

function field_group_attach_groups(&$element, $context) {
  $entity_type = $context['entity_type'];
  $bundle = $context['bundle'];
  $mode = $context['mode'];
  $display_context = $context['display_context'];
  $element['#fieldgroups'] = field_group_info_groups($entity_type, $bundle, $display_context, $mode);

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