这是我的错,因为我没有完全理解权限功能的工作原理。我没有意识到只需要一个函数来容纳所有表单权限。以下代码效果很好。希望它能帮助像我一样不那么聪明的其他人:
function glatfelter_supplier_action_register_menu() {
$items = array();
$items['sar_performance_form'] = array(
'title' => 'SAR Performance',
'description' => 'SAR Performance Form',
'page callback' => 'drupal_get_form',
'page arguments' => array('sar_performance_form'),
'access callback' => 'user_access',
'access arguments' => array('QCA SAR Performance Form Access'),
);
$items['sar_sdr_form'] = array(
'title' => 'SAR SDR/NCR',
'description' => 'SAR SDR Form',
'page callback' => 'drupal_get_form',
'page arguments' => array('sar_sdr_form'),
'access callback' => 'user_access',
'access arguments' => array('QCA SAR SDR Form Access'),
);
return $items;
}
//***PEFORMANCE FORM***
function sar_performance_form($form, &$form_state) {
//Display the overview
$form['fs_sar_performance_overview'] = array(
'#type' => 'fieldset',
'#title' => t('Overview'),
);
$form['fs_sar_performance_overview']['sar_performance_overview'] = array(
'#markup' => t('Performance form overview goes here'),
);
//Display the form
$form['sar_performance_something'] = array(
'#markup' => 'Form input can start here',
);
return $form;
}
//***SDR FORM***
function sar_sdr_form($form, &$form_state) {
//Display the overview
$form['fs_sar_sdr_overview'] = array(
'#type' => 'fieldset',
'#title' => t('Overview'),
);
$form['fs_sar_sdr_overview']['sar_sdr_overview'] = array(
'#markup' => t('SDR form overview goes here'),
);
//Display the form
$form['sar_sdr_something'] = array(
'#markup' => 'Form input can start here',
);
return $form;
}
//This function adds the forms to the permissions menu
function glatfelter_supplier_action_register_permission() {
return array(
'QCA SAR Performance Form Access' => array(
'title' => t('QCA SAR Performance Form Access'),
'description' => t('Allows users to access the SAR Performance form.'),
),
'QCA SAR SDR Form Access' => array(
'title' => t('QCA SAR SDR Form Access'),
'description' => t('Allows users to access the SAR SDR form.'),
),
);
}