public static LanguageConfiguration::processLanguageConfiguration(&$element, FormStateInterface $form_state, &$form)
Process handler for the language_configuration form element.
File
- core/modules/language/src/Element/LanguageConfiguration.php, line 33
Class
- LanguageConfiguration
- Provides language element configuration.
Namespace
Drupal\language\Element
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | public static function processLanguageConfiguration(& $element , FormStateInterface $form_state , & $form ) { $options = isset( $element [ '#options' ]) ? $element [ '#options' ] : array (); // Avoid validation failure since we are moving the '#options' key in the // nested 'language' select element. unset( $element [ '#options' ]); /** @var \Drupal\language\Entity\ContentLanguageSettings $default_config */ $default_config = $element [ '#default_value' ]; $element [ 'langcode' ] = array ( '#type' => 'select' , '#title' => t( 'Default language' ), '#options' => $options + static ::getDefaultOptions(), '#description' => t( 'Explanation of the language options is found on the <a href=":languages_list_page">languages list page</a>.' , array ( ':languages_list_page' => \Drupal::url( 'entity.configurable_language.collection' ))), '#default_value' => ( $default_config != NULL) ? $default_config ->getDefaultLangcode() : LanguageInterface::LANGCODE_SITE_DEFAULT, ); $element [ 'language_alterable' ] = array ( '#type' => 'checkbox' , '#title' => t( 'Show language selector on create and edit pages' ), '#default_value' => ( $default_config != NULL) ? $default_config ->isLanguageAlterable() : FALSE, ); // Add the entity type and bundle information to the form if they are set. // They will be used, in the submit handler, to generate the names of the // configuration entities that will store the settings and are a way to uniquely // identify the entity. $language = $form_state ->get( 'language' ) ? : []; $language += array ( $element [ '#name' ] => array ( 'entity_type' => $element [ '#entity_information' ][ 'entity_type' ], 'bundle' => $element [ '#entity_information' ][ 'bundle' ], ), ); $form_state ->set( 'language' , $language ); // Do not add the submit callback for the language content settings page, // which is handled separately. if ( $form [ '#form_id' ] != 'language_content_settings_form' ) { // Determine where to attach the language_configuration element submit // handler. // @todo Form API: Allow form widgets/sections to declare #submit // handlers. $submit_name = isset( $form [ 'actions' ][ 'save_continue' ]) ? 'save_continue' : 'submit' ; if (isset( $form [ 'actions' ][ $submit_name ][ '#submit' ]) && array_search ( 'language_configuration_element_submit' , $form [ 'actions' ][ $submit_name ][ '#submit' ]) === FALSE) { $form [ 'actions' ][ $submit_name ][ '#submit' ][] = 'language_configuration_element_submit' ; } elseif ( array_search ( 'language_configuration_element_submit' , $form [ '#submit' ]) === FALSE) { $form [ '#submit' ][] = 'language_configuration_element_submit' ; } } return $element ; } |
Please login to continue.