You are here

function field_group_field_group_form_process in Field Group 8.3

Implements hook_field_group_form_process().

File

./field_group.module, line 430
Allows administrators to attach field groups.

Code

function field_group_field_group_form_process(array &$element, &$group, &$complete_form) {

  // Add all field_group format types to the js settings.
  $element['#attached']['drupalSettings']['field_group'] = [
    $group->format_type => [
      'mode' => $group->mode,
      'context' => $group->context,
      'settings' => $group->format_settings,
    ],
  ];
  $element['#weight'] = $group->weight;

  // Call the pre render function for the format type.
  $manager = Drupal::service('plugin.manager.field_group.formatters');
  $plugin = $manager
    ->getInstance([
    'format_type' => $group->format_type,
    'configuration' => [
      'label' => $group->label,
      'settings' => $group->format_settings,
    ],
    'group' => $group,
  ]);
  if ($plugin) {
    $plugin
      ->process($element, $complete_form);
  }
}