嗨,我正在创建一个类似于 drupal 7 中的用户表的 tableselect。我在屏幕上显示“没有可用的插件”的空消息。即使正在数组中获取记录。这是我的代码
function massignite_menu() {
$items = array();
$items['massig/manage'] = array(
'page callback' => 'massignite_selector',
'file' => 'manage.inc',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function massignite_selector() {
include('massrpc.php');
$header = array(
'plugin' => t('Plugin'),
'status' => t('Status'),
);
$params = array(
'username' => "foo",
'password' => "bar",
);
$pluginsRecords = xmlGetPlugins($params);
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;
}
我按照这里给出的教程进行操作。任何帮助将不胜感激
编辑: - 解决了它!显然,我通过 menu_hook 错误地调用了我的函数。正确的做法是这样的。
function massignite_menu() {
$items = array();
$items['massig/manage'] = array(
'title' => 'Plugins',
'page callback' => 'drupal_get_form',
'page arguments' => array('massignite_table_form'),
'file' => 'manage.inc',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);