public LanguageAddForm::validateCustom(array $form, FormStateInterface $form_state)
Validates the language addition form on custom language button.
File
- core/modules/language/src/Form/LanguageAddForm.php, line 110
Class
- LanguageAddForm
- Controller for language addition forms.
Namespace
Drupal\language\Form
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public function validateCustom( array $form , FormStateInterface $form_state ) { if ( $form_state ->getValue( 'predefined_langcode' ) == 'custom' ) { $langcode = $form_state ->getValue( 'langcode' ); // Reuse the editing form validation routine if we add a custom language. $this ->validateCommon( $form [ 'custom_language' ], $form_state ); if ( $language = $this ->languageManager->getLanguage( $langcode )) { $form_state ->setErrorByName( 'langcode' , $this ->t( 'The language %language (%langcode) already exists.' , array ( '%language' => $language ->getName(), '%langcode' => $langcode ))); } } else { $form_state ->setErrorByName( 'predefined_langcode' , $this ->t( 'Use the <em>Add language</em> button to save a predefined language.' )); } } |
Please login to continue.