Same name and namespace in other branches
  1. 7.x-2.x includes/admin.inc \quicktabs_form() 1 comment
  2. 7.x-3.x quicktabs.admin.inc \quicktabs_form() 1 comment

Build the quicktab creation and edit form.

1 string reference to 'quicktabs_form'
quicktabs_clone in ./quicktabs.admin.inc
Clone QuickTabs.

File

./quicktabs.admin.inc, line 22

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;
}