function language_form_alter
language_form_alter(&$form, FormStateInterface $form_state)
Implements hook_form_alter().
File
- core/modules/language/language.module, line 404
- Add language handling functionality to Drupal.
Code
function language_form_alter(&$form, FormStateInterface $form_state) { // Content entity forms may have added a langcode field. But content language // configuration should decide if it should be exposed or not in the forms. $form_object = $form_state->getFormObject(); if ($form_object instanceof ContentEntityFormInterface && $form_object->getEntity()->getEntityType()->hasKey('langcode')) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $form_object->getEntity(); $entity_type = $entity->getEntityType(); $langcode_key = $entity_type->getKey('langcode'); if (isset($form[$langcode_key])) { $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle($entity->getEntityTypeId(), $entity->bundle()); $form[$langcode_key]['#access'] = $language_configuration->isLanguageAlterable(); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!language!language.module/function/language_form_alter/8.1.x