You are here

function field_group_easy_responsive_tabs_field_group_format_settings in Field Group: Easy Responsive Tabs to Accordion 7

Implements hook_field_group_format_settings().

File

./field_group_easy_responsive_tabs.module, line 99
Module file for the field_group_easy_responsive_tabs module.

Code

function field_group_easy_responsive_tabs_field_group_format_settings($group) {

  // Add a wrapper for extra settings to use by others.
  $form = array(
    'instance_settings' => array(
      '#tree' => TRUE,
      '#weight' => 5,
    ),
  );
  $field_group_types = field_group_formatter_info();
  $mode = $group->mode == 'form' ? 'form' : 'display';
  $formatter = $field_group_types[$mode][$group->format_type];

  // Add optional instance_settings.
  switch ($group->format_type) {
    case 'field_group_easy_responsive_tabs_nav':

      // 'type': default, vertical, accordion.
      $form['instance_settings']['type'] = array(
        '#title' => t('Type'),
        '#description' => t('default, vertical, accordion'),
        '#type' => 'select',
        '#options' => array(
          'default' => 'Default',
          'vertical' => 'Vertical',
          'accordion' => 'Accordion',
        ),
        '#default_value' => isset($group->format_settings['instance_settings']['type']) ? $group->format_settings['instance_settings']['type'] : $formatter['instance_settings']['type'],
        '#weight' => 1,
      );

      // 'width': auto or any custom width.
      $form['instance_settings']['width'] = array(
        '#title' => t('Width'),
        '#description' => t('auto or any custom width'),
        '#type' => 'textfield',
        '#default_value' => isset($group->format_settings['instance_settings']['width']) ? $group->format_settings['instance_settings']['width'] : $formatter['instance_settings']['width'],
        '#weight' => 1.5,
      );

      // 'fit': 100% fits in a container.
      $form['instance_settings']['fit'] = array(
        '#title' => t('Fit'),
        '#description' => t('100% fits in a container'),
        '#type' => 'select',
        '#options' => array(
          0 => t('No'),
          1 => t('Yes'),
        ),
        '#default_value' => isset($group->format_settings['instance_settings']['fit']) ? $group->format_settings['instance_settings']['fit'] : $formatter['instance_settings']['fit'],
        '#weight' => 1.5,
      );

      // 'close': Close the panels on start, the options 'accordion' and 'tabs'
      // keep them closed in there respective view types.
      $form['instance_settings']['closed'] = array(
        '#title' => t('Closed'),
        '#description' => t('Close the panels on start, the options "accordion" and "tabs" keep them closed in there respective view types.'),
        '#type' => 'select',
        '#options' => array(
          0 => t('No'),
          1 => t('Yes'),
        ),
        '#default_value' => isset($group->format_settings['instance_settings']['closed']) ? $group->format_settings['instance_settings']['closed'] : $formatter['instance_settings']['closed'],
        '#weight' => 1.5,
      );

      // Activate: Callback function, gets called if tab is switched.
      // TODO: make an option.
      // 'activetab_bg': background color for active tabs in this group.
      $form['instance_settings']['activetab_bg'] = array(
        '#title' => t('Active tab bg'),
        '#description' => t('background color for active tabs in this group'),
        '#type' => 'textfield',
        '#default_value' => isset($group->format_settings['instance_settings']['activetab_bg']) ? $group->format_settings['instance_settings']['activetab_bg'] : $formatter['instance_settings']['activetab_bg'],
        '#weight' => 1.5,
      );

      // 'inactive_bg': background color for inactive tabs in this group.
      $form['instance_settings']['inactive_bg'] = array(
        '#title' => t('Inactive tab bg'),
        '#description' => t('background color for inactive tabs in this group'),
        '#type' => 'textfield',
        '#default_value' => isset($group->format_settings['instance_settings']['inactive_bg']) ? $group->format_settings['instance_settings']['inactive_bg'] : $formatter['instance_settings']['inactive_bg'],
        '#weight' => 1.5,
      );

      // 'active_border_color': border color for active tabs heads in this group.
      $form['instance_settings']['active_border_color'] = array(
        '#title' => t('Active border color'),
        '#description' => t('border color for active tabs heads in this group'),
        '#type' => 'textfield',
        '#default_value' => isset($group->format_settings['instance_settings']['active_border_color']) ? $group->format_settings['instance_settings']['active_border_color'] : $formatter['instance_settings']['active_border_color'],
        '#weight' => 1.5,
      );

      // 'active_content_border_color': border color for active tabs contect in
      // this group so that it matches the tab head border.
      $form['instance_settings']['active_content_border_color'] = array(
        '#title' => t('Active content border color'),
        '#description' => t('border color for active tabs contect in this group so that it matches the tab head border'),
        '#type' => 'textfield',
        '#default_value' => isset($group->format_settings['instance_settings']['active_content_border_color']) ? $group->format_settings['instance_settings']['active_content_border_color'] : $formatter['instance_settings']['active_content_border_color'],
        '#weight' => 1.5,
      );

      // 'tabidentify': The tab groups identifier *This should be a unique name
      // for each tab group and should not be defined in any styling or css file.
      $form['instance_settings']['tabidentify'] = array(
        '#title' => t('The tab groups identifier'),
        '#description' => t('The tab groups identifier *This should be a unique name for each tab group and should not be defined in any styling or css file.'),
        '#type' => 'textfield',
        '#default_value' => isset($group->format_settings['instance_settings']['tabidentify']) ? $group->format_settings['instance_settings']['tabidentify'] : $formatter['instance_settings']['tabidentify'],
        '#weight' => 2,
      );
      break;
    default:
      break;
  }
  return $form;
}