You are here

public static function ConfigTranslationFormBase::createFormElement in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::createFormElement()
  2. 9 core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::createFormElement()

Creates a form element builder.

Parameters

\Drupal\Core\TypedData\TypedDataInterface $schema: Schema definition of configuration.

Return value

\Drupal\config_translation\FormElement\ElementInterface|null The element builder object if possible.

4 calls to ConfigTranslationFormBase::createFormElement()
ConfigTranslationFormBase::buildForm in core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
Implements \Drupal\Core\Form\FormInterface::buildForm().
ConfigTranslationFormBase::submitForm in core/modules/config_translation/src/Form/ConfigTranslationFormBase.php
Form submission handler.
ListElement::getTranslationBuild in core/modules/config_translation/src/FormElement/ListElement.php
Builds a render array containing the source and translation form elements.
ListElement::setConfig in core/modules/config_translation/src/FormElement/ListElement.php
Sets configuration based on a nested form value array.

File

core/modules/config_translation/src/Form/ConfigTranslationFormBase.php, line 238

Class

ConfigTranslationFormBase
Provides a base form for configuration translations.

Namespace

Drupal\config_translation\Form

Code

public static function createFormElement(TypedDataInterface $schema) {
  $definition = $schema
    ->getDataDefinition();

  // Form element classes can be specified even for non-translatable elements
  // such as the ListElement form element which is used for Mapping and
  // Sequence schema elements.
  if (isset($definition['form_element_class'])) {
    if (!$definition
      ->getLabel()) {
      $definition
        ->setLabel(new TranslatableMarkup('n/a'));
    }
    $class = $definition['form_element_class'];
    return $class::create($schema);
  }
}