Setting Values for TableSelect checkboxes Is there anyway to set the default values for checkboxes? What im trying to do is set a specific value for each checkbox so it will delete the selected row in my db, however table select seems to just go off of its own value instead of the one I am trying to assign them with.

    function auto_form_records($form, &amp;$form_state) {
//Table header
    $header = array(
        '',
        'First Name', 
        'Last Name', 
    );

//DB query
    $dbresult = db_query("SELECT * FROM {auto}");

        foreach ($dbresult as $dbrow) {

            $select_id[] = array(
            $dbrow-&gt;id
            );
            $rows[] = array(
            $dbrow-&gt;firstname,
            $dbrow-&gt;lastname,
            );
        }

//Table select Form     
    $form['checkboxes'] = array(
        '#type' =&gt; 'tableselect',
        '#header' =&gt; $header,
        '#options' =&gt; $rows,
        '#empty' =&gt; 'No Records were found.',
        '#default_value' =&gt; $select_id
    );

    $form['submit'] = array(
            '#type' =&gt; 'submit',
            '#value' =&gt; t('Submit'),
    );
        return $form;
    }

//Delete row in db.   
    function auto_form_delete_row($form, &amp;$form_state){
        $id = $form_state['values']['checkboxes'];
        db_delete('autoleads')
      -&gt;condition('id', $id)
      -&gt;execute();
    }

//Submission    
    function auto_form_records_submit($form, &amp;$form_state){
        $data = drupal_set_message(t(dvm($form_state)));
        //auto_form_delete_row($form, $form_state);
        return $data;
    }


I would think that me passing the string into default_value would atleast give me the values I am trying to pass through, but its not...

Any suggestions is appreciated.
You just need to add your id as the key for each item in your $rows array, e.g.:

foreach ($dbresult as $dbrow) {
  $rows[$dbrow-&gt;id] = array(
    $dbrow-&gt;firstname,
    $dbrow-&gt;lastname,
  );
}


Then in your submit handler run:

// Limit the checkbox ids to only those selected by the user
$selected = array_filter($form_state['values']['checkboxes']);

db_delete('autoleads')
  -&gt;condition('id', $selected, 'IN')
  -&gt;execute();


And you should be good to go :)

There's no need to use #default_value unless you want to pre-select some of the checkboxes for the user. If you do, just set #default_value to an array of the ids that you want selected initially.