When I press the delete button on some content, I'm taken to a confirmation page. The delete option is a button, while the cancel option is a link. That looks pretty weird. I found that there's a form_confirm() function in drupal, but I can't understand how to use it. Does anyone know how to make the cancel link into a button?
Or this using no javascript (and replacing eregi() with preg_match()...
if ( $form['#theme'] == 'confirm_form' ) {
$no = $form['actions']['cancel']['#value'];
if (!is_null($no)) {
// Get the text to put on the cancel button
$value = preg_replace('/(<\/?)(\w+)([^>]*>)/e', '', $no);
preg_match('/href\s*=\s*\"([^\"]+)\"/', $no, $href);
$form['actions']['cancel']['#value'] = '';
$form['href']=array(
'#type'=>'value',
'#value'=>$href[1],
);
// Add our own button
$form['actions']['docancel'] = array(
'#type' => 'submit',
'#name' => 'cancel',
'#submit' => array('mymodule_confirm_form_cancel'),
'#value' => $value,
);
}
}
and
function mymodule_confirm_form_cancel(&$form,&$form_state) {
$href=$form['href']['#value'];
if ( !is_null($href) ) {
$form['#redirect']=$href;
}
}