I am creating a simple basic module that alters the text of a submit button and should change the default creation message with drupal_set_message()
.
I've found an example about changing the message, and changed the code a little.
function ask_admin_form_alter(&$form, $form_state, $form_id) {
if ($form_id == "vragen_node_form") {
$form['actions']['submit']['#value'] = 'Stel Uw Vraag';
$form['buttons']['submit']['#submit'][0] = 'ask_admin_node_form_submit';
}
}
function ask_admin_node_form_submit($form, &$form_state) {
global $user;
$node = node_form_submit_build_node($form, $form_state);
$insert = empty($node->nid);
node_save($node);
$node_link = l(t('view'), 'node/'. $node->nid);
$watchdog_args = array('@type' => $node->type, '%title' => $node->title);
$t_args = array('@type' => node_get_types('name', $node), '%title' => $node->title);
if ($insert) {
watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('Uw vraag is met succes ontvangen en zal zo spoedig mogelijk beantwoord worden.', $t_args));
}
else {
watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
drupal_set_message(t('U heeft uw vraag met succes gewijzigd.', $t_args));
}
if ($node->nid) {
unset($form_state['rebuild']);
$form_state['nid'] = $node->nid;
$form_state['redirect'] = 'node/'. $node->nid;
}
else {
// In the unlikely case something went wrong on save, the node will be
// rebuilt and node form redisplayed the same way as in preview.
drupal_set_message(t('Er ging iets mis bij het verzenden van uw vraag.'), 'error');
}
}
Although the form button is indeed changed to my own text, the message won't change when the node is created.
When I copy and paste the whole tutorial, my node messages won't change, but I also get no error messages.
Does anyone knows what is wrong, or how I can change the message using other code?