You are here

function quicktabs_form in Quick Tabs 7.3

Same name and namespace in other branches
  1. 5 quicktabs.module \quicktabs_form()
  2. 6.3 includes/admin.inc \quicktabs_form()
  3. 6 quicktabs.module \quicktabs_form()
  4. 6.2 includes/admin.inc \quicktabs_form()
  5. 7.2 includes/admin.inc \quicktabs_form()

Build the quicktab creation and edit form.

2 string references to 'quicktabs_form'
quicktabs_clone in ./quicktabs.admin.inc
Clone QuickTabs.
quicktabs_menu in ./quicktabs.module
Implements hook_menu().

File

./quicktabs.admin.inc, line 71
Provides the Quicktabs administrative interface.

Code

function quicktabs_form($form, &$form_state, $formtype, $qt = NULL) {
  if (!isset($qt)) {
    $qt = new stdClass();
  }
  $form = _quicktabs_admin_main_form($form_state, $qt);

  // If creating a new Quicktabs instance, start off with 2 empty tabs.
  if (empty($qt->tabs)) {
    $qt->tabs = array(
      0 => array(),
      1 => array(),
    );
  }

  // If the "Add another" button was clicked, we need to increment the number of
  // tabs by one.
  if (isset($form_state['num_tabs']) && $form_state['num_tabs'] > count($qt->tabs)) {
    $qt->tabs[] = array();
  }
  $form_state['num_tabs'] = count($qt->tabs);

  // If the "Remove" button was clicked for a tab, we need to remove that tab
  // from the form.
  if (isset($form_state['to_remove'])) {
    unset($qt->tabs[$form_state['to_remove']]);
    unset($form_state['to_remove']);
    $form_state['num_tabs']--;
  }
  $tab_titles = array(
    QUICKTABS_DELTA_NONE => t('- None -'),
  );

  // Add current tabs to the form.
  foreach ($qt->tabs as $delta => $tab) {
    $tab['delta'] = $delta;
    $form['qt_wrapper']['tabs'][$delta] = _quicktabs_form($tab, $qt);
    if (isset($tab['title'])) {
      $tab_titles[$delta] = $tab['title'];
    }
  }

  // If there's only one tab, it shouldn't be removeable.
  if (count($qt->tabs) == 1) {
    $form['qt_wrapper']['tabs'][$delta]['remove']['#access'] = FALSE;
  }
  $form['default_tab'] = array(
    '#type' => 'select',
    '#title' => t('Default tab'),
    '#options' => $tab_titles,
    '#default_value' => isset($qt->default_tab) ? $qt->default_tab : 0,
    '#access' => !empty($tab_titles),
    '#weight' => -5,
  );
  return $form;
}