function ConfigTranslationFormBase::createFormElement

Same name in other branches
  1. 9 core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::createFormElement()
  2. 8.9.x core/modules/config_translation/src/Form/ConfigTranslationFormBase.php \Drupal\config_translation\Form\ConfigTranslationFormBase::createFormElement()
  3. 10 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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.