You are here

function _qt_admin_main_form in Quick Tabs 6.2

Same name and namespace in other branches
  1. 6.3 includes/admin.inc \_qt_admin_main_form()
1 call to _qt_admin_main_form()
quicktabs_form in includes/admin.inc
Build the quicktab creation and edit form.

File

includes/admin.inc, line 89

Code

function _qt_admin_main_form($form_state, &$quicktabs) {
  $form['#cache'] = TRUE;

  // the contents of $quicktabs will either come from the db or from $form_state
  if (isset($form_state['quicktabs'])) {
    $quicktabs = $form_state['quicktabs'] + (array) $quicktabs;
  }
  $form['title'] = array(
    '#title' => t('Block title'),
    '#type' => 'textfield',
    '#description' => t('This will appear as the name of this block in administer >> site building >> blocks.'),
    '#default_value' => isset($quicktabs['title']) ? $quicktabs['title'] : '',
    '#weight' => -10,
  );
  $form['style'] = array(
    '#type' => 'select',
    '#title' => t('Style'),
    '#options' => quicktabs_style_options(),
    '#default_value' => isset($quicktabs['style']) ? $quicktabs['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($quicktabs['ajax']) ? $quicktabs['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($quicktabs['hide_empty_tabs']) ? $quicktabs['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="quicktabs-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' => 'add-tab',
      'title' => t('Click here to add more tabs.'),
    ),
    '#weight' => 1,
    '#submit' => array(
      'qt_more_tabs_submit',
    ),
    // If no javascript action.
    '#ahah' => array(
      'path' => 'quicktabs/ahah',
      'wrapper' => 'quicktabs-tabs',
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );
  $form['submit_form'] = array(
    '#type' => 'submit',
    '#weight' => 10,
    '#value' => t('Save'),
  );
  return $form;
}