views:

15

answers:

1

I have a content type and I wish to edit the submit function. I thought the way you would do this would be as follows:

function moduleName_contentType_node_form_submit($form, &$form_state){
    drupal_set_message(t('Test'));
}

I cleared the cached but the message is not being displayed on the screen. Am I doing this correctly or do I need to use form_alter? If so how would I do that?

A: 

In this case too you can use form alter, and add

$form['#submit'][] = 'your_sumbmit_callback';

or if you want to completely change the submit and do your own thing:

$form['#submit'] = array('your_submit_callback');

And obviously the callback function needs to be defined;

function your_submit_callback( $form, &$form_state) {
  drupal_set_message('hello');
}
DKinzer

related questions