Commit 2c3f9537 authored by Steven Wittens's avatar Steven Wittens
Browse files

#84250: Allow usage of query string on confirm forms.

parent 5cb01fd5
...@@ -2124,6 +2124,7 @@ function system_node_type($op, $info) { ...@@ -2124,6 +2124,7 @@ function system_node_type($op, $info) {
* block <em>foo</em>?"). * block <em>foo</em>?").
* @param $path * @param $path
* The page to go to if the user denies the action. * 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'.
* @param $description * @param $description
* Additional text to display (defaults to "This action cannot be undone."). * Additional text to display (defaults to "This action cannot be undone.").
* @param $yes * @param $yes
...@@ -2138,6 +2139,16 @@ function system_node_type($op, $info) { ...@@ -2138,6 +2139,16 @@ function system_node_type($op, $info) {
*/ */
function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') { function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
$description = ($description) ? $description : t('This action cannot be undone.'); $description = ($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); drupal_set_title($question);
$form['#attributes'] = array('class' => 'confirmation'); $form['#attributes'] = array('class' => 'confirmation');
$form['description'] = array('#value' => $description); $form['description'] = array('#value' => $description);
...@@ -2145,7 +2156,7 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, ...@@ -2145,7 +2156,7 @@ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL,
$form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>'); $form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm')); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
$form['actions']['cancel'] = array('#value' => l($no ? $no : t('Cancel'), $path)); $form['actions']['cancel'] = array('#value' => $cancel);
$form['#base'] = 'confirm_form'; $form['#base'] = 'confirm_form';
return $form; return $form;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment