public function FormElementBase::getTranslationBuild in Drupal 9
Same name and namespace in other branches
- 8 core/modules/config_translation/src/FormElement/FormElementBase.php \Drupal\config_translation\FormElement\FormElementBase::getTranslationBuild()
Builds a render array containing the source and translation form elements.
Parameters
\Drupal\Core\Language\LanguageInterface $source_language: The source language of the configuration object.
\Drupal\Core\Language\LanguageInterface $translation_language: The language to display the translation form for.
mixed $source_config: The configuration value of the element in the source language.
mixed $translation_config: The configuration value of the element in the language to translate to.
array $parents: Parents array for the element in the form.
string|null $base_key: (optional) Base key to be used for the elements in the form. NULL for top-level form elements.
Return value
array A render array consisting of the source and translation elements for the source value.
Overrides ElementInterface::getTranslationBuild
File
- core/
modules/ config_translation/ src/ FormElement/ FormElementBase.php, line 53
Class
- FormElementBase
- Provides a common base class for form elements.
Namespace
Drupal\config_translation\FormElementCode
public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) {
$build['#theme'] = 'config_translation_manage_form_element';
// For accessibility we make source and translation appear next to each
// other in the source for each element, which is why we utilize the
// 'source' and 'translation' sub-keys for the form. The form values,
// however, should mirror the configuration structure, so that we can
// traverse the configuration schema and still access the right
// configuration values in ConfigTranslationFormBase::setConfig().
// Therefore we make the 'source' and 'translation' keys the top-level
// keys in $form_state['values'].
$build['source'] = $this
->getSourceElement($source_language, $source_config);
$build['translation'] = $this
->getTranslationElement($translation_language, $source_config, $translation_config);
$build['source']['#parents'] = array_merge([
'source',
], $parents);
$build['translation']['#parents'] = array_merge([
'translation',
], $parents);
return $build;
}