You are here

function field_group_field_ui_create_vertical_tabs in Field Group 8

Same name and namespace in other branches
  1. 8.3 includes/field_ui.inc \field_group_field_ui_create_vertical_tabs()
  2. 7.2 field_group.field_ui.inc \field_group_field_ui_create_vertical_tabs()
  3. 7 field_group.field_ui.inc \field_group_field_ui_create_vertical_tabs()

Create vertical tabs.

1 call to field_group_field_ui_create_vertical_tabs()
field_group_field_ui_display_form_alter in includes/field_ui.inc
Function to alter the display overview screens.

File

includes/field_ui.inc, line 311
Field_group.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).

Code

function field_group_field_ui_create_vertical_tabs(&$form, &$form_state, $params) {
  $form_state
    ->set('field_group_params', $params);
  $existing_group_config = \Drupal::configFactory()
    ->listAll('field_group.' . $params->entity_type . '.' . $params->bundle);
  $displays = array();
  foreach ($existing_group_config as $config) {
    $group = \Drupal::config($config)
      ->get();
    if ($group['context'] == $params->context && $group['mode'] == $params->mode) {
      continue;
    }
    $displays[$group['context'] . '.' . $group['mode']] = $group['context'] . ':' . $group['mode'];
  }

  // No displays to clone.
  if (empty($displays)) {
    return;
  }

  // Add additional settings vertical tab.
  if (!isset($form['additional_settings'])) {
    $form['additional_settings'] = array(
      '#type' => 'vertical_tabs',
      '#theme_wrappers' => array(
        'vertical_tabs',
      ),
      '#prefix' => '<div>',
      '#suffix' => '</div>',
      '#tree' => TRUE,
    );
  }

  // Add extra guidelines for webmaster.
  $form['field_group'] = array(
    '#type' => 'details',
    '#group' => 'additional_settings',
    '#title' => t('Fieldgroups'),
    '#description' => t('<p class="fieldgroup-help">Fields can be dragged into groups with unlimited nesting. Each fieldgroup format comes with a configuration form, specific for that format type.<br />Note that some formats come in pair. These types have a html wrapper to nest its fieldgroup children. E.g. Place accordion items into the accordion, vertical tabs in vertical tab group and horizontal tabs in the horizontal tab group. There is one exception to this rule, you can use a vertical tab without a wrapper when the additional settings tabs are available. E.g. node forms.</p>'),
    '#collapsible' => TRUE,
    '#open' => TRUE,
  );
  $form['field_group']['fieldgroup_clone'] = array(
    '#title' => t('Select source display'),
    '#description' => t('Clone fieldgroups from selected display to the current display'),
    '#type' => 'select',
    '#options' => $displays,
    '#default_value' => 'none',
  );
  $form['field_group']['fieldgroup_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Clone'),
    '#validate' => array(
      'field_group_field_ui_clone_field_groups_validate',
    ),
    '#submit' => array(
      'field_group_field_ui_clone_field_groups',
    ),
  );
}