protected function FormElementBase::getSourceElement in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config_translation/src/FormElement/FormElementBase.php \Drupal\config_translation\FormElement\FormElementBase::getSourceElement()
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.
1 call to FormElementBase::getSourceElement()
- FormElementBase::getTranslationBuild in core/
modules/ config_translation/ src/ FormElement/ FormElementBase.php - Builds a render array containg the source and translation form elements.
2 methods override FormElementBase::getSourceElement()
- PluralVariants::getSourceElement in core/
modules/ config_translation/ src/ FormElement/ PluralVariants.php - Returns the source element for a given configuration definition.
- TextFormat::getSourceElement in core/
modules/ config_translation/ src/ FormElement/ TextFormat.php - Returns the source element for a given configuration definition.
File
- core/
modules/ config_translation/ src/ FormElement/ FormElementBase.php, line 93 - Contains \Drupal\config_translation\FormElement\FormElementBase.
Class
- FormElementBase
- Provides a common base class for form elements.
Namespace
Drupal\config_translation\FormElementCode
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(
'@label' => $this->definition
->getLabel(),
'@source_language' => $source_language
->getName(),
)),
'#markup' => $value,
);
}