Drupal Form API tableselect programmatically check or uncheck checkbox I followed this code example and built up my own version of how I want to use the tableselect. I want to use the table select for configurations. To do this I need programmatically check or uncheck a checkbox. How would I go about doing this.

Here is the general idea of my code

function my_form($form, $form_state) {
  $users = array(
    array('uid' =&gt; 1, 'first_name' =&gt; 'Indy', 'last_name' =&gt; 'Jones'),
    array('uid' =&gt; 2, 'first_name' =&gt; 'Darth', 'last_name' =&gt; 'Vader'),
    array('uid' =&gt; 3, 'first_name' =&gt; 'Super', 'last_name' =&gt; 'Man'),
  );

  $header = array(
    'first_name' =&gt; t('First Name'),
    'last_name' =&gt; t('Last Name'),
  );
  $options = array();
  foreach ($users as $user) {
    $options[$user['uid']] =array(
      'first_name' =&gt; $user['first_name'],
      'last_name' =&gt; $user['last_name'],
    );
  }
  $form['table'] = array(
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $options,
    '#empty' =&gt; t('No users found'),
  );
  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit'),
  );
  return $form;
}


I am hoping/guessing it something simple like setting something in the options array.
I fixed this I understand how #default_value works now. It has to be an array.

$values = array();

$values[1] = TRUE;
$values[2] = FALSE;
$values[3] = TRUE;

$form['table'] = array(
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $options,
    '#default_value' =&gt; $values,
    '#empty' =&gt; t('No campground to claim'),
  );