Follow-up from
#111715-194: Convert node/content types into configuration →
Problem/Motivation
Currently all core entities have own implementation for language element value.
That means that following hunk is copy/pasted all over
+++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.phpundefined
@@ -76,10 +100,32 @@ protected function actions(array $form, array &$form_state) {
+ // Add the language configuration submit handler. This is needed because the
+ // submit button has custom submit handlers.
+ if (\Drupal::moduleHandler()->moduleExists('language')) {
+ array_unshift($actions['submit']['#submit'],'language_configuration_element_submit');
+ array_unshift($actions['submit']['#submit'], array($this, 'languageConfigurationSubmit'));
+ }
+ // We cannot leverage the regular submit handler definition because we have
+ // button-specific ones here. Hence we need to explicitly set it for the
+ // submit action, otherwise it would be ignored.
+ if (\Drupal::moduleHandler()->moduleExists('translation_entity')) {
+ array_unshift($actions['submit']['#submit'], 'translation_entity_language_configuration_element_submit');
...
+ * Submit handler to update the bundle for the default language configuration.
+ */
+ public function languageConfigurationSubmit(array &$form, array &$form_state) {
+ // Since the machine name is not known yet, and it can be changed anytime,
+ // we have to also update the bundle property for the default language
+ // configuration in order to have the correct bundle value.
+ $form_state['language']['default_language']['bundle'] = $form_state['values']['id'];
+ }
Proposed resolution
As solution we can move this hack to one place to process element and allow core entities to provide alterable language settings
+++ b/core/modules/language/language.moduleundefined
@@ -320,6 +322,18 @@ function language_configuration_element_process($element, &$form_state, &$form)
+ // Do not add the submit callback for the language content settings page,
+ // which is handled separately.
+ if (array_search('language_content_settings_form_submit', $form['#submit']) === FALSE) {
+ // Determine where to attach the language_configuration element submit handler.
+ // @todo Form API: Allow form widgets/sections to declare #submit handlers.
+ if (isset($form['actions']['submit']['#submit']) && array_search('language_configuration_element_submit', $form['actions']['submit']['#submit']) === FALSE) {
+ $form['actions']['submit']['#submit'][] = 'language_configuration_element_submit';
+ }
+ elseif (array_search('language_configuration_element_submit', $form['#submit']) === FALSE) {
+ $form['#submit'][] = 'language_configuration_element_submit';
+ }
Related Issues
#111715-194: Convert node/content types into configuration →
#1945226-102: Add language selector on menus →