theme_confirm

Versions
4.6
theme_confirm($question, $path, $description = NULL, $yes = NULL, $no = NULL, $extra = NULL, $name = 'confirm')

Output a confirmation form

This function outputs a complete form for confirming an action. A link is offered to go back to the item that is being changed in case the user changes his/her mind.

You should use $_POST['edit'][$name] (where $name is usually 'confirm') to check if the confirmation was successful.

Parameters

$question The question to ask the user (e.g. "Are you sure you want to delete the block <em>foo</em>?").

$path The page to go to if the user denies the action.

$description Additional text to display (defaults to "This action cannot be undone.").

$yes A caption for the button which confirms the action (e.g. "Delete", "Replace", ...).

$no A caption for the link which denies the action (e.g. "Cancel").

$extra Additional HTML to inject into the form, for example form_hidden()s.

$name The internal name used to refer to the confirmation item.

Return value

A themed HTML string representing the form.

Related topics

Code

includes/theme.inc, line 901

<?php
function theme_confirm($question, $path, $description = NULL, $yes = NULL, $no = NULL, $extra = NULL, $name = 'confirm') {
  drupal_set_title($question);

  if (is_null($description)) {
    $description = t('This action cannot be undone.');
  }

  $output .= '<p>'. $description ."</p>\n";
  if (!is_null($extra)) {
    $output .= $extra;
  }
  $output .= '<div class="container-inline">';
  $output .= form_submit($yes ? $yes : t('Confirm'));
  $output .= l($no ? $no : t('Cancel'), $path);
  $output .= "</div>\n";

  $output .= form_hidden($name, 1);
  return form($output, 'post', NULL, array('class' => 'confirmation'));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.