You are here

function tabsexample_form in Tabs (jQuery UI tabs) 6

Generate an example set of tabs.

1 string reference to 'tabsexample_form'
tabsexample_menu in docs/tabsexample.module
Implementation of hook_menu().

File

docs/tabsexample.module, line 37

Code

function tabsexample_form() {
  $form = array();
  $form['example1'] = array(
    '#type' => 'tabset',
  );
  $form['example1']['tab1'] = array(
    // #type and #title are the minimum requirements.
    '#type' => 'tabpage',
    '#title' => t('One'),
    // This will be the content of the tab.
    '#content' => t('First tab content.') . theme('item_list', array(
      l(t('one'), 'node'),
      l(t('two'), 'node'),
      l(t('three'), 'node'),
    )),
  );
  $form['example1']['tab2'] = array(
    '#type' => 'tabpage',
    '#title' => t('Two'),
    '#content' => t('Second tab content.'),
  );

  // Nest a second tabset.
  $form['example1']['tab2']['tabset2'] = array(
    '#type' => 'tabset',
  );
  $form['example1']['tab2']['tabset2']['tab1'] = array(
    '#type' => 'tabpage',
    '#title' => t('One'),
    '#content' => t('First tab content.'),
  );

  // #content not needed as we are adding child elements.
  $form['example1']['tab2']['tabset2']['tab2'] = array(
    '#type' => 'tabpage',
    '#title' => t('Two'),
  );

  // Place a standard form element (in this case, a textfield) on a tab.
  $form['example1']['tab2']['tabset2']['tab2']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
  );
  $form['example1']['tab3'] = array(
    '#type' => 'tabpage',
    '#title' => t('Three'),
    '#content' => t('Third tab content.'),
    // Select this as the active tab at startup.
    '#selected' => TRUE,
  );
  return $form;
}