confirm_form

Versions
4.7
confirm_form($form_id, $form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm')
5 – 7
confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm')

Output a confirmation form

This function returns 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 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. Can be either a drupal path, or an array with the keys 'path', 'query', 'fragment'.

$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

The form.

▾ 28 functions call confirm_form()

aggregator_admin_remove_feed in modules/aggregator/aggregator.module
block_box_delete in modules/block/block.module
Menu callback; confirm deletion of custom blocks.
comment_confirm_delete in modules/comment/comment.module
comment_multiple_delete_confirm in modules/comment/comment.module
List the selected comments and verify that the admin really wants to delete them.
contact_admin_delete in modules/contact/contact.module
Category delete page.
filter_admin_delete in modules/filter/filter.module
Menu callback; confirm deletion of a format.
forum_confirm_delete in modules/forum/forum.module
Returns a confirmation page for deleting a forum taxonomy term.
locale_admin_manage_delete_form in modules/locale/locale.module
User interface for the language deletion confirmation screen.
locale_string_delete_form in modules/locale/locale.module
User interface for the string deletion confirmation screen.
menu_confirm_disable_item in modules/menu/menu.module
Menu callback; hide a menu item.
menu_item_delete_form in modules/menu/menu.module
Menu callback; delete a single custom item.
menu_reset_item in modules/menu/menu.module
Menu callback; reset a single modified item.
node_configure_rebuild_confirm in modules/node/node.module
Menu callback: confirm rebuilding of permissions.
node_delete_confirm in modules/node/node.module
Menu callback -- ask for confirmation of node deletion
node_multiple_delete_confirm in modules/node/node.module
node_revision_delete_confirm in modules/node/node.module
Ask confirmation for revision deletion to prevent against CSRF attacks.
node_revision_revert_confirm in modules/node/node.module
Ask for confirmation of the reversion to prevent against CSRF attacks.
node_type_delete_confirm in modules/node/content_types.inc
Menu callback; delete a single content type.
path_admin_delete_confirm in modules/path/path.module
Menu callback; confirms deleting an URL alias
profile_field_delete in modules/profile/profile.module
Menu callback; deletes a field from all user profiles.
search_wipe_confirm in modules/search/search.module
Menu callback: confirm wiping of the index.
system_modules_confirm_form in modules/system/system.module
system_modules_uninstall_confirm_form in modules/system/system.module
Confirm uninstall of selected modules.
taxonomy_term_confirm_delete in modules/taxonomy/taxonomy.module
taxonomy_vocabulary_confirm_delete in modules/taxonomy/taxonomy.module
user_admin_access_delete_confirm in modules/user/user.module
Menu callback: delete an access rule
user_confirm_delete in modules/user/user.module
user_multiple_delete_confirm in modules/user/user.module

Code

modules/system/system.module, line 2152

<?php
function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
  $description = isset($description) ? $description : t('This action cannot be undone.');

  // Prepare cancel link
  $query = $fragment = NULL;
  if (is_array($path)) {
    $query = isset($path['query']) ? $path['query'] : NULL;
    $fragment = isset($path['fragment']) ? $path['fragment'] : NULL;
    $path = isset($path['path']) ? $path['path'] : NULL;
  }
  $cancel = l($no ? $no : t('Cancel'), $path, array(), $query, $fragment);

  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' => $cancel);
  $form['#base'] = 'confirm_form';
  return $form;
}
?>
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.