Here is a way to globally replace all the cancel links on the confirm delete node pages...
<?php
function MYMODULE_form_alter($form_id, &$form) {
// ...code...
if ($form_id == 'node_delete_confirm') {
_MYMODULE_form_alter_node_delete_confirm($form);
}
// ...code...
}
function _MYMODULE_form_alter_node_delete_confirm(&$form) {
if (is_array($form['actions']['cancel'])) {
// convert the html from the link into an xml object to get at its attributes
$o = simplexml_load_string($form['actions']['cancel']['#value']);
// replace the link with a new button
// NOTE: jQuery is added afterwards to convert the button type from a submit to a button
$form['actions']['cancel'] = array(
'#type' => 'button',
'#value' => 'Cancel',
'#attributes' => array(
'onClick' => "window.location = '" . urldecode($o['href']) . "';",
),
'#suffix' => "
<script type='text/javascript'>
$(document).ready(function(){
$('form#node-delete-confirm input#edit-cancel').attr('type', 'button');
});
</script>"
);
}
}
?>










Forgive my ignorance, but
Forgive my ignorance, but where does one add this code to make it work?
Thanks,.. it works in D6 as well
Thanks.. it works in D6 as well.
This is what i did:
<?php$form['actions']['cancel'] = array(
'#type' => 'button',
'#value' => 'Cancel',
'#attributes' => array(
'onclick' => "javascript:history.go(-1); return false;",
),
);
?>
This is a great idea, but I'm
This is a great idea, but I'm having trouble making it work. Basically, it puts the new url into the location of the browser, but doesn't actually change the page. Seems that the same form_id is used for both the edit and delete operations for taxonomy terms ('taxonomy_form_term'). Any ideas to get past this issue?
Thanks!
tj
Drupal 5
Just a heads up, I wrote this article a while back for Drupal 5. Are you coding for Drupal 5 or 6? -Eric