4.7.x system.module confirm_form($form_id, $form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm')
5.x system.module confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm')
6.x system.module confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm')
7.x system.module confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = 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.

If the submit handler for this form is invoked, the user successfully confirmed the action. You should never directly inspect $_POST to see if an action was confirmed.

Parameters

$form_id: The unique form identifier. Used by the form API to construct the theme.

$form: Additional elements to inject into the form, for example hidden elements.

$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").

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

Return value

A themed HTML string representing the form.

21 calls to confirm_form()
aggregator_admin_remove_feed in modules/aggregator.module
block_box_delete in modules/block.module
Menu callback; confirm deletion of custom blocks.
comment_delete in modules/comment.module
Menu callback; delete a comment.
contact_admin_delete in modules/contact.module
Category delete page.
filter_admin_delete in modules/filter.module
Menu callback; confirm deletion of a format.

... See full list

File

modules/system.module, line 1263
Configuration system that lets administrators modify the workings of the site.

Code

function confirm_form($form_id, $form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
  $description = $description ? $description : t('This action cannot be undone.');
  drupal_set_title($question);
  $form['#attributes'] = array(
    'class' => 'confirmation',
  );
  $form['description'] = array(
    '#value' => $description,
  );
  $form[$name] = array(
    '#type' => 'hidden',
    '#value' => 1,
  );
  $form['actions'] = array(
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $yes ? $yes : t('Confirm'),
  );
  $form['actions']['cancel'] = array(
    '#value' => l($no ? $no : t('Cancel'), $path),
  );
  return drupal_get_form($form_id, $form, 'confirm_form');
}