0

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!'));

}
4

1 回答 1

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!'));
}

希望对您有所帮助... :)

于 2013-09-20T07:49:05.423 回答