function language_configuration_element_submit
Same name in other branches
- 9 core/modules/language/language.module \language_configuration_element_submit()
- 10 core/modules/language/language.module \language_configuration_element_submit()
- 11.x core/modules/language/language.module \language_configuration_element_submit()
Submit handler for the forms that have a language_configuration element.
4 string references to 'language_configuration_element_submit'
- BlockContentTypeForm::form in core/
modules/ block_content/ src/ BlockContentTypeForm.php - Gets the actual form array to be built.
- CommentTypeForm::form in core/
modules/ comment/ src/ CommentTypeForm.php - Gets the actual form array to be built.
- LanguageConfiguration::processLanguageConfiguration in core/
modules/ language/ src/ Element/ LanguageConfiguration.php - Process handler for the language_configuration form element.
- LanguageConfigurationElement::buildForm in core/
modules/ language/ tests/ language_elements_test/ src/ Form/ LanguageConfigurationElement.php - Form constructor.
File
-
core/
modules/ language/ language.module, line 185
Code
function language_configuration_element_submit(&$form, FormStateInterface $form_state) {
// Iterate through all the language_configuration elements and save their
// values.
// In case we are editing a bundle, we must check the new bundle name,
// because e.g. hook_ENTITY_update fired before.
if ($language = $form_state->get('language')) {
foreach ($language as $element_name => $values) {
$entity_type_id = $values['entity_type'];
$bundle = $values['bundle'];
$form_object = $form_state->getFormObject();
if ($form_object instanceof EntityFormInterface) {
/** @var \Drupal\Core\Entity\EntityFormInterface $form_object */
$entity = $form_object->getEntity();
if ($entity->getEntityType()
->getBundleOf()) {
$bundle = $entity->id();
$language[$element_name]['bundle'] = $bundle;
}
}
$config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle);
$config->setDefaultLangcode($form_state->getValue([
$element_name,
'langcode',
]));
$config->setLanguageAlterable($form_state->getValue([
$element_name,
'language_alterable',
]));
$config->save();
// Set the form_state language with the updated bundle.
$form_state->set('language', $language);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.