public function LanguageAddForm::validatePredefined in Drupal 9
Same name and namespace in other branches
- 8 core/modules/language/src/Form/LanguageAddForm.php \Drupal\language\Form\LanguageAddForm::validatePredefined()
- 10 core/modules/language/src/Form/LanguageAddForm.php \Drupal\language\Form\LanguageAddForm::validatePredefined()
Element specific validator for the Add language button.
File
- core/
modules/ language/ src/ Form/ LanguageAddForm.php, line 131
Class
- LanguageAddForm
- Controller for language addition forms.
Namespace
Drupal\language\FormCode
public function validatePredefined($form, FormStateInterface $form_state) {
$langcode = $form_state
->getValue('predefined_langcode');
if ($langcode == 'custom') {
$form_state
->setErrorByName('predefined_langcode', $this
->t('Fill in the language details and save the language with <em>Add custom language</em>.'));
}
else {
if ($language = $this->languageManager
->getLanguage($langcode)) {
$form_state
->setErrorByName('predefined_langcode', $this
->t('The language %language (%langcode) already exists.', [
'%language' => $language
->getName(),
'%langcode' => $langcode,
]));
}
}
}