1 redirect.admin.inc | redirect_edit_form_validate($form, &$form_state) |
Form validate handler; validate an URL redirect
See also
File
- core/
modules/ redirect/ redirect.admin.inc, line 579 - Admin page callbacks for the Redirect module.
Code
function redirect_edit_form_validate($form, &$form_state) {
form_state_values_clean($form_state);
$values = $form_state['values'];
// Get rid of form values not appropriate for Redirect creation.
unset($values['override']);
unset($values['delete']);
$redirect = new Redirect($values);
if (empty($form_state['values']['override'])) {
if ($existing = redirect_load_by_source($redirect->source, $redirect->langcode)) {
if ($redirect->rid != $existing->rid && $redirect->langcode == $existing->langcode) {
// The "from" path should not conflict with another redirect
$form_state['storage']['override_messages']['redirect-conflict'] = t('The base source path %source is already being redirected. Do you want to <a href="@edit-page">edit the existing redirect</a>?', array('%source' => $redirect->source, '@edit-page' => url('admin/config/urls/redirect/edit/' . $existing->rid)));
$form_state['rebuild'] = TRUE;
}
}
}
redirect_validate($redirect, $form, $form_state);
$form_state['redirect'] = $redirect;
}