I'm trying to add a checkbox column in the admin table part of my module. The idea is to add checkboxes at the beginning of each row, like in the normal admin content management form.
My table is build in a form function with the following code :
function myform_admin_form($form, &$form_state) {
$query = db_select('form_xml', 'f');
$query->join('form_xml_status', 's', 's.id = f.id');
$query->join('users', 'u', 'u.uid = f.uid');
$result = $query
->condition('s.status', 'todo', '=')
->fields('f')
->fields('u', array('name'))
->execute()
->fetchAll();
$header = array(
array('data' => t('ID')),
array('data' => t('Name')),
array('data' => t('User')),
);
foreach($result as $key){
$rows[] = array(
array('data' => t($key->id)),
array('data' => t($key->name)),
array('data' => t($key->user))
);
}
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
);
$output = theme('table', array('header' => $header, 'rows' => $rows));
$output .= $form;
return $output;
}
My tableselect doesn't display at all, but "Array" appears at the bottom of the table. Is it possible to add checkboxes in a table like this ?