function path_admin_form_validate

Form validation handler for path_admin_form().

See also

path_admin_form_submit()

path_admin_form_delete_submit()

File

modules/path/path.admin.inc, line 196

Code

function path_admin_form_validate($form, &$form_state) {
    $source =& $form_state['values']['source'];
    $source = drupal_get_normal_path($source);
    $alias = $form_state['values']['alias'];
    $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
    // Language is only set if locale module is enabled, otherwise save for all languages.
    $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE;
    $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array(
        ':pid' => $pid,
        ':alias' => $alias,
        ':language' => $language,
    ))->fetchField();
    if ($has_alias) {
        form_set_error('alias', t('The alias %alias is already in use in this language.', array(
            '%alias' => $alias,
        )));
    }
    if (!drupal_valid_path($source)) {
        form_set_error('source', t("The path '@link_path' is either invalid or you do not have access to it.", array(
            '@link_path' => $source,
        )));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.