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

The main section of admin page.

1 call to _quicktabs_admin_main_form()
quicktabs_form in includes/admin.inc
Build the quicktab creation and edit form.

File

includes/admin.inc, line 203

Code

function _quicktabs_admin_main_form($form_state, &$quicktab) {
    $form['#cache'] = TRUE;
    // The contents of $quicktab will either come from the db or from $form_state.
    if (isset($form_state['values']['title'])) {
        $quicktab = _quicktabs_convert_form_to_quicktab($form_state);
    }
    if (empty($quicktab->machine_name)) {
        $form['machine_name'] = array(
            '#title' => t('Machine Name'),
            '#type' => 'textfield',
            '#description' => t('A unique ID that will be used internally and in the CSS ID of your quicktabs block. must contain only lowercase letters, numbers, and underscores.'),
            '#default_value' => '',
            '#weight' => -8,
            '#required' => TRUE,
        );
    }
    else {
        $form['machine_name'] = array(
            '#type' => 'value',
            '#value' => $quicktab->machine_name,
        );
        $form['machine_name_display'] = array(
            '#title' => t('Machine-readable name'),
            '#type' => 'item',
            '#value' => "<code>{$quicktab->machine_name}</code>",
            '#description' => t('The machine name will be used internally by quicktabs and will be used in the CSS ID of your quicktabs block.'),
            '#weight' => -8,
        );
    }
    $form['title'] = array(
        '#title' => t('Block title'),
        '#description' => t('This will appear as the name of this block in administer >> site building >> blocks.'),
        '#type' => 'textfield',
        '#default_value' => isset($quicktab->title) ? $quicktab->title : '',
        '#weight' => -10,
    );
    $styles = module_invoke_all('quicktabs_tabstyles');
    $style_options = array();
    // The keys used for options must be valid html id-s.
    foreach ($styles as $style) {
        $style_options[$style] = $style;
    }
    ksort($style_options);
    $form['style'] = array(
        '#type' => 'select',
        '#title' => t('Style'),
        '#options' => array(
            'nostyle' => t('No style'),
        ) + array(
            'default' => t('Default style'),
        ) + $style_options,
        '#default_value' => isset($quicktab->style) ? $quicktab->style : 'default',
        '#description' => t('Choose the quicktab style.'),
        '#weight' => -8,
    );
    $form['ajax'] = array(
        '#type' => 'radios',
        '#title' => t('Ajax'),
        '#options' => array(
            TRUE => t('Yes') . ': ' . t('Load only the first tab on page view'),
            FALSE => t('No') . ': ' . t('Load all tabs on page view.'),
        ),
        '#default_value' => isset($quicktab->ajax) ? $quicktab->ajax : 0,
        '#description' => t('Choose how the content of tabs should be loaded.<p>By choosing "Yes", only the first tab will be loaded when the page first viewed. Content for other tabs will be loaded only when the user clicks the other tab. This will provide faster initial page loading, but subsequent tab clicks will be slower. This can place less load on a server.</p><p>By choosing "No", all tabs will be loaded when the page is first viewed. This will provide slower initial page loading, and more server load, but subsequent tab clicks will be faster for the user. Use with care if you have heavy views.</p><p>Warning: if you enable Ajax, any block you add to this quicktabs block will be accessible to anonymous users, even if you place role restrictions on the quicktabs block. Do not enable Ajax if the quicktabs block includes any blocks with potentially sensitive information.</p>'),
        '#weight' => -6,
    );
    $form['hide_empty_tabs'] = array(
        '#type' => 'checkbox',
        '#title' => t('Hide empty tabs'),
        '#default_value' => isset($quicktab->hide_empty_tabs) ? $quicktab->hide_empty_tabs : 0,
        '#description' => t('Empty and restricted tabs will not be displayed. Could be useful when the tab content is not accessible.<br />This option does not work in ajax mode.'),
        '#weight' => -4,
    );
    // Add a wrapper for the tabs and Add Another Tab button.
    $form['qt_wrapper'] = array(
        '#tree' => FALSE,
        '#weight' => -3,
        '#prefix' => '<div class="clear-block" id="quicktabs-tabs-wrapper">',
        '#suffix' => '</div>',
    );
    $form['qt_wrapper']['tabs'] = array(
        '#tree' => TRUE,
        '#prefix' => '<div id="quicktab-tabs">',
        '#suffix' => '</div>',
        '#theme' => 'quicktabs_admin_form_tabs',
    );
    $form['qt_wrapper']['tabs_more'] = array(
        '#type' => 'submit',
        '#prefix' => '<div id="add-more-tabs-button">',
        '#suffix' => '<label for="edit-tabs-more">' . t('Add tab') . '</label></div>',
        '#value' => t('More tabs'),
        '#attributes' => array(
            'class' => array(
                'add-tab',
            ),
            'title' => t('Click here to add more tabs.'),
        ),
        '#weight' => 1,
        '#submit' => array(
            'qt_more_tabs_submit',
        ),
        '#ajax' => array(
            'callback' => 'quicktabs_ajax_callback',
            'wrapper' => 'quicktab-tabs',
            'effect' => 'fade',
        ),
        '#limit_validation_errors' => array(),
    );
    $form['submit_form'] = array(
        '#type' => 'submit',
        '#weight' => 10,
        '#value' => t('Save'),
    );
    return $form;
}