Setting up form table checkboxes I'm trying to create a form table with a column of checkboxes. The theming isn't working with the code below. All help is appreciated :)

myadmin.module

function myadmin_menu() {

  $weight=0;

  $t = get_t();

  $items = array();

  $items['myadmin_dispute'] = array(
    'title' =&gt; 'Dispute Queue',
    'access arguments' =&gt; array('view myadmin'),
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('myadmin_dispute'),
    'file' =&gt; 'myadmin_dispute.php',
    'type' =&gt; MENU_NORMAL_ITEM,
    'expanded' =&gt; true,
    'weight' =&gt; $weight++,
    'menu_name' =&gt; 'myadmin',
    'module' =&gt; 'myadmin',
  );
}


myadmin_dispute.php

function myadmin_dispute($form_state) {
    //add output - css and javascript to include
    drupal_add_js ( drupal_get_path ( 'module', 'myadmin' ) . '/scripts/jquery.tablesorter.js' );
    drupal_add_js ( drupal_get_path ( 'module', 'myadmin' ) . '/scripts/myadmin.js' );
    drupal_add_css ( drupal_get_path ( 'module', 'myadmin' ) . '/blue/style.css' );


    $disputes = array
      (
        array('uid' =&gt; 1, 'first' =&gt; 'Joe', 'last' =&gt; 'Smith'),
        array('uid' =&gt; 2, 'first' =&gt; 'Susan', 'last' =&gt; 'Doe'),
        array('uid' =&gt; 3, 'first' =&gt; 'John', 'last' =&gt; 'Doe'),
      );

    foreach($disputes as $dispute)
      {
        $checkboxes[$dispute['uid']] = ''; 
        $form[$dispute['uid']]['first_name'] = array 
        (
          '#value' =&gt; $dispute['first'],
        );
        $form[$dispute['uid']]['last_name'] = array 
        (
          '#value' =&gt; $dispute['last'],
        );
      }


    $form['checkboxes'] = array
      (
        '#type' =&gt; 'checkboxes',
        '#options' =&gt; $checkboxes, 
      );
      $form['#theme'] = 'dispute_theme';

      return $form;

}


function myadmin_dispute_theme()
{
  return array
  (
    'dispute_theme' =&gt; array
    (
      'arguments' =&gt; array('form' =&gt; NULL),
    ),
  );
}


function theme_dispute_theme($form)
{
  $rows = array();
  foreach(element_children($form['checkboxes']) as $uid) 
  {
    $row = array(); 
    $row[] = drupal_render($form['checkboxes'][$uid]); 
    $row[] = drupal_render($form[$uid]['first_name']); 
    $row[] = drupal_render($form[$uid]['last_name']); 
    $rows[] = $row;
  }

  if(count($rows))
  {
    $header = array(theme('table_select_header_cell') , t('First Name'), t('Last Name')); 
  }
  else
  {
    $header = array(t('First Name'), t('Last Name')); 
    $row = array();
    $row[] = array
    (
      'data' =&gt; t('No users were found'),
      'colspan' =&gt; 2,
      'style' =&gt; 'text-align:center',
    );
    $rows[] = $row;
  }

  $output = theme('table', $header, $rows);
  return $output . drupal_render($form); 
}


function myadmin_dispute_submit($form_id, &amp;$form_state) {   

}




Update, this is needs to work for drupal 6 instance.
Drupal has a built-in tableselect element type for situations just like this, it would be a lot easier to use that instead:

$disputes = array(
  1 =&gt; array('Joe', 'Smith'),
  2 =&gt; array('Susan', 'Doe'),
  3 =&gt; array('John', 'Doe')
);

$header = array(t('First Name'), t('Last Name'));

$form['checkboxes'] = array(
  '#type' =&gt; 'tableselect',
  '#header' =&gt; $header,
  '#options' =&gt; $disputes,
  '#empty' =&gt; 'No users were found.'
);


The above code produces this table:



In your form submit function you can get the selected user ids with code like this:

$selected_uids = array_filter($form_state['values']['checkboxes']);


EDIT

The above is for Drupal 7, if you're using Drupal 6 you can use the same code but you need to install the Elements module.