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, &$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->id
);
$rows[] = array(
$dbrow->firstname,
$dbrow->lastname,
);
}
//Table select Form
$form['checkboxes'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#empty' => 'No Records were found.',
'#default_value' => $select_id
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
//Delete row in db.
function auto_form_delete_row($form, &$form_state){
$id = $form_state['values']['checkboxes'];
db_delete('autoleads')
->condition('id', $id)
->execute();
}
//Submission
function auto_form_records_submit($form, &$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.