public LanguageAddForm::validatePredefined($form, FormStateInterface $form_state)
Element specific validator for the Add language button.
File
- core/modules/language/src/Form/LanguageAddForm.php, line 128
Class
- LanguageAddForm
- Controller for language addition forms.
Namespace
Drupal\language\Form
Code
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.', array('%language' => $language->getName(), '%langcode' => $langcode))); } } }
Please login to continue.