You are here

function quicktabs_form in Quick Tabs 7.2

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.3 quicktabs.admin.inc \quicktabs_form()

Build the quicktab creation and edit form.

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

File

includes/admin.inc, line 154
Provides the Quick Tabs' administrative interface.

Code

function quicktabs_form($form, &$form_state, $formtype, $quicktab = NULL) {
  if (!isset($quicktab)) {
    $quicktab = new stdClass();
  }
  $form = _quicktabs_admin_main_form($form_state, $quicktab);
  if (empty($quicktab->tabs)) {
    $quicktab->tabs = array(
      0 => array(),
      1 => array(),
    );
  }
  if (isset($form_state['num_tabs']) && $form_state['num_tabs'] > count($quicktab->tabs)) {
    $quicktab->tabs[] = array();
  }
  $form_state['num_tabs'] = count($quicktab->tabs);
  if (isset($form_state['to_remove'])) {
    unset($quicktab->tabs[$form_state['to_remove']]);
    unset($form_state['to_remove']);
    $form_state['num_tabs']--;
  }
  $tab_titles = array();

  // Add current tabs to the form.
  foreach ($quicktab->tabs as $delta => $tab) {
    $tab['delta'] = $delta;
    $form['qt_wrapper']['tabs'][$delta] = _quicktabs_form($tab);
    if (isset($tab['title'])) {
      $tab_titles[$delta] = $tab['title'];
    }
  }
  $form['default_tab'] = array(
    '#type' => 'select',
    '#title' => t('Default tab'),
    '#options' => $tab_titles,
    '#default_value' => isset($quicktab->default_tab) ? $quicktab->default_tab : 0,
    '#access' => !empty($tab_titles),
    '#weight' => -5,
  );
  return $form;
}