function locale_languages_predefined_form_validate
7.x locale.admin.inc | locale_languages_predefined_form_validate($form, &$form_state) |
6.x locale.inc | locale_languages_predefined_form_validate($form, &$form_state) |
Validate the language addition form.
Related topics
1 string reference to 'locale_languages_predefined_form_validate'
- locale_languages_custom_form in drupal-6.x/
includes/ locale.inc - Custom language addition form.
File
- drupal-6.x/
includes/ locale.inc, line 289 - Administration functions for locale.module.
Code
function locale_languages_predefined_form_validate($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode)));
}
if (!isset($form_state['values']['name'])) {
// Predefined language selection.
$predefined = _locale_get_predefined_list();
if (!isset($predefined[$langcode])) {
form_set_error('langcode', t('Invalid language code.'));
}
}
else {
// Reuse the editing form validation routine if we add a custom language.
locale_languages_edit_form_validate($form, $form_state);
}
}