Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I tried creating a tableselect similar to admin page user list admin/people in drupal 7. I am getting empty message displayed on the screen even though the records are passed to the tableselect as options.
function MY_MODULE_menu() {
$items = array();
$items['MY_MODULE/manage'] = array(
'page callback' => 'MY_MODULE_selector',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function MY_MODULE_selector() {
$header = array(
'plugin' => t('Plugin'),
'status' => t('Status'),
);
$params = array(
'username' => "foo",
'password' => "bar",
);
$pluginsRecords = ///fetching data from db
foreach ($pluginsRecords as $key=>$plugin) {
$options[$key] = array(
'plugin' => $plugin['Name'],
'status' => $plugin['is_active']?'Activated':'Deactivated',
);
}
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No plugins available.'),
'#multiple' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Activate'),
);
$form['pager'] = array('#markup' => theme('pager'));
return $form;
}
I debugged the working and found that "form_process_tableselect" in form.inc gets invoked when the core user list page is build up but is not called when my form is invoked.
I also tried copying the same code as that of the user.admin.inc in my module file but the function didn't got called.
Comments
Comment #1
sadashiv CreditAttribution: sadashiv commentedI found my mistake
I need to pass the page callback drupal_get_form
so the code becomes