getSourceElement example

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;
  }

  /** * 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. * * @param \Drupal\Core\Language\LanguageInterface $source_language * Thee source language of the configuration object. * @param mixed $source_config * The configuration value of the element in the source language. * * @return array * A render array for the source value. */
Home | Imprint | This part of the site doesn't use cookies.