You are here

function rules_action_drupal_goto_form in Rules 6

Action "Page redirect" configuration form

Related topics

File

rules/modules/system.rules_forms.inc, line 118
Rules configuration forms for the system module

Code

function rules_action_drupal_goto_form($settings = array(), &$form, $form_state) {
  $settings += array(
    'path' => '',
    'query' => '',
    'fragment' => '',
    'force' => 0,
  );

  // For settings backward compatibility respect the override setting as default
  $settings += array(
    'immediate' => isset($settings['override']) && !$settings['override'],
  );
  $form['settings']['path'] = array(
    '#type' => 'textfield',
    '#size' => 30,
    '#prefix' => '<br /><div class="container-inline">',
    '#title' => t('To'),
    '#default_value' => $settings['path'],
  );
  $form['settings'][] = array(
    '#value' => '?',
  );
  $form['settings']['query'] = array(
    '#type' => 'textfield',
    '#size' => 12,
    '#default_value' => $settings['query'],
  );
  $form['settings'][] = array(
    '#value' => '#',
  );
  $form['settings']['fragment'] = array(
    '#type' => 'textfield',
    '#size' => 12,
    '#default_value' => $settings['fragment'],
    '#suffix' => '</div>',
  );
  $form['settings']['force'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force redirecting to the given path, even if a destination parameter is given'),
    '#description' => t("Per default drupal doesn't redirect to the given path, if a destination parameter is set. Instead it redirects to the given destination parameter. Most times, the destination parameter is set by appending it to the URL, e.g. !example_url", array(
      '!example_url' => 'http://example.com/user/login?destination=node/2',
    )),
    '#default_value' => $settings['force'],
    '#weight' => 7,
  );
  $form['settings']['immediate'] = array(
    '#type' => 'checkbox',
    '#title' => t('Immediately issue the page redirect'),
    '#description' => t("Use this with <em>caution</em>! If checked, the path redirect is issued immediately, so the normal execution flow is interrupted."),
    '#default_value' => $settings['immediate'],
    '#weight' => 8,
  );
}