1 redirect.admin.inc redirect_element_validate_redirect($element, &$form_state)

Element validate handler; validate the redirect of an URL redirect.

See also

redirect_edit_form()

File

core/modules/redirect/redirect.admin.inc, line 518
Administrative page callbacks for the Redirect module.

Code

function redirect_element_validate_redirect($element, &$form_state) {
  $parsed = _redirect_extract_url_options($element, $form_state);
  if (!url_is_external($parsed['url'])) {
    $value = backdrop_get_normal_path($parsed['url'], $form_state['values']['langcode']);
  }
  else {
    $value = $parsed['url'];
  }
  form_set_value($element, $value, $form_state);

  if (!valid_url($value) && !valid_url($value, TRUE) && $value != '<front>' && $value != '' && !file_exists($value)) {
    form_error($element, t('The redirect path %value is not valid.', array('%value' => $value)));
  }

  return $element;
}