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 に答える