tab hack with the use of tab module

  1. function parliament_history_form(&$node) {
  2.   //keep hold of current tab
  3.   //this is so that it doesnt jump to
  4.   //first tab when pae is refreshed or previewed
  5.   $pjscript = '$(document).ready(function(){
  6.                $("#example > ul").tabs();
  7.               });';
  8.   drupal_add_js( $pjscript,'inline');
  9.  
  10.  
  11.   $form['personal'] = array(
  12.     '#type'  => 'fieldset',
  13.     '#tree'  => TRUE,
  14.     //the class sets it up as a tab
  15.     //creae the tab buttons with with the <ul> each tab seperated by <il> tags
  16.     //each tab is defined by <div> an the appropriate id.
  17.     '#prefix'=>' <div id="example" class="drupal-tabs">    
  18.                   <ul class="anchors">
  19.                     <li><a href="#names">Names</a></li>
  20.                        <li><a href="#dates_address">DoB & Address</a></li>
  21.                   </ul>
  22.                   <div id="names">');
  23.                    
  24.   $form['personal']['title_before'] = array(
  25.   '#type' => 'select',
  26.   '#default_value' => $node->title_after,
  27.   '#options' => array(
  28.     '' => 'Select title',
  29.     'Hon.' => 'Hon',
  30.     'Lord' => 'Lord',
  31.     'Sir' => 'Sir',
  32.     ),
  33.   );
  34.   $form['personal']['surname'] = array(
  35.     '#type' => 'textfield',
  36.     '#default_value' => $node->surname,
  37.   );
  38.  
  39.   $form['name_footnote']['note'] = array(
  40.     '#type' => 'textarea',
  41.     '#default_value' => $node->name_footnote,
  42.   );
  43.  
  44.   $form ['dates']  = array(
  45.     '#type'  => 'fieldset',
  46.     '#tree'  => TRUE,
  47.     //close the old tab and start the new tab
  48.     '#prefix' => '</div><div id="dates_address">'
  49.   );
  50.  
  51.   $form['dates']['dob']['markup'] = array(
  52.     '#type'  => 'item',
  53.     '#title' => t('DoB'),
  54.  
  55.   );
  56.  
  57.   $form['dates']['dob']['prefix'] = array(
  58.   '#type' => 'select',
  59.   '#title' => t('prefix'),
  60.   '#default_value' => $node->dob_prefix,
  61.   '#options' => array(
  62.     '' => '',
  63.     'aft' => 'aft',
  64.     'bef' => 'bef',
  65.     'c' => 'c',
  66.     'd' => 'd',
  67.     '?' => '?',
  68.     '?c' => '?c',
  69.     ),
  70.   );
  71.  
  72.   $form['dates']['dob']['year'] = array(
  73.      '#type' => 'textfield',
  74.      '#title' => 'year (yyyy)',
  75.      '#default_value' => $node->dob,
  76.      '#suffix'=>'</div>',
  77.   );
  78.  
  79. return $form;
  80.  
  81. }