drupal 7工作正常。
/**
* Implementation of hook_form_alter().
*/
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'form_id':
$form['actions']['submit']['#submit'][] = 'MY_MODULE_custom_submit';
break;
}
}
function MY_MODULE_custom_submit($form, &$form_state)
{
//Get current messages and clear them.
$messages = drupal_get_messages('status');
drupal_set_message(t('Your custom status message here!'));
}
答案 0 :(得分:3)
只需要在那里获得正确的form_id
。因此,如果节点类型为article
,请使用article_node_form
。
此外,请不要忘记清除admin/config/development/performance
处的缓存,以便系统看到更改。
/**
* Implementation of hook_form_alter().
*/
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
// Replace NODETYPE with the machine-readable name of the node type.
case 'NODETYPE_node_form':
$form['actions']['submit']['#submit'][] = 'MY_MODULE_custom_submit';
break;
}
}
function MY_MODULE_custom_submit($form, &$form_state) {
//Get current messages and clear them.
$messages = drupal_get_messages('status');
drupal_set_message(t('Your custom status message here!'));
}
希望有帮助......:)