protected FormElementBase::getSourceElement(LanguageInterface $source_language, $source_config)
Returns the source element for a given configuration definition.
This can be either a render array that actually outputs the source values directly or a read-only form element with the source values depending on what is considered to provide a more intuitive user interface for the translator.
Parameters
\Drupal\Core\Language\LanguageInterface $source_language: Thee source language of the configuration object.
mixed $source_config: The configuration value of the element in the source language.
Return value
array A render array for the source value.
File
- core/modules/config_translation/src/FormElement/FormElementBase.php, line 88
Class
- FormElementBase
- Provides a common base class for form elements.
Namespace
Drupal\config_translation\FormElement
Code
protected function getSourceElement(LanguageInterface $source_language, $source_config) { if ($source_config) { $value = '<span lang="' . $source_language->getId() . '">' . nl2br($source_config) . '</span>'; } else { $value = $this->t('(Empty)'); } return array( '#type' => 'item', '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array( // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@source_language' => $source_language->getName(), )), '#markup' => $value, ); }
Please login to continue.