public ContentTranslationHandler::entityFormSharedElements($element, FormStateInterface $form_state, $form)
Process callback: determines which elements get clue in the form.
See also
\Drupal\content_translation\ContentTranslationHandler::entityFormAlter()
File
- core/modules/content_translation/src/ContentTranslationHandler.php, line 491
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translation
Code
public function entityFormSharedElements($element, FormStateInterface $form_state, $form) {
static $ignored_types;
// @todo Find a more reliable way to determine if a form element concerns a
// multilingual value.
if (!isset($ignored_types)) {
$ignored_types = array_flip(array('actions', 'value', 'hidden', 'vertical_tabs', 'token', 'details'));
}
foreach (Element::children($element) as $key) {
if (!isset($element[$key]['#type'])) {
$this->entityFormSharedElements($element[$key], $form_state, $form);
}
else {
// Ignore non-widget form elements.
if (isset($ignored_types[$element[$key]['#type']])) {
continue;
}
// Elements are considered to be non multilingual by default.
if (empty($element[$key]['#multilingual'])) {
// If we are displaying a multilingual entity form we need to provide
// translatability clues, otherwise the shared form elements should be
// hidden.
if (!$form_state->get(['content_translation', 'translation_form'])) {
$this->addTranslatabilityClue($element[$key]);
}
else {
$element[$key]['#access'] = FALSE;
}
}
}
}
return $element;
}
Please login to continue.