function locale_languages_predefined_form_validate
Validate the language addition form.
Related topics
1 string reference to 'locale_languages_predefined_form_validate'
- locale_languages_custom_form in modules/
locale/ locale.admin.inc - Custom language addition form.
File
-
modules/
locale/ locale.admin.inc, line 324
Code
function locale_languages_predefined_form_validate($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
if (($duplicate = db_query("SELECT COUNT(*) FROM {languages} WHERE language = :language", array(
':language' => $langcode,
))->fetchField()) != 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.
include_once DRUPAL_ROOT . '/includes/iso.inc';
$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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.