- function mymodule_form_alter(&$form, &$form_state, $form_id)
- {
- if($form['form_id']['#value'] =='formvalue')
- {
- if($form['buttons']['submit']['#submit']){
- $form['buttons']['submit']['#submit'][] = 'mymodule_submit_function';
- }
- }
- }
- function mymodule_submit_function($form, &$form_state){
- global $_SESSION;
- $insert = empty($form_state['values']['nid']);
- if($insert){
- //Write your custom message text here
- if($form['nid']['#post']['form_id'] == 'formvalue'){
- $keys = array_keys($_SESSION['messages']['status']);
- $last_key = end($keys);
- $message = 'My custom messge after node save';
- $_SESSION['messages']['status'][$last_key] = $message;
- }
- }
- }
Friday, 1 May 2015
How to set a custom message using form_alter in Drupal
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment