Textarea.php

Same filename in this branch
  1. 11.x core/lib/Drupal/Core/Render/Element/Textarea.php
Same filename and directory in other branches
  1. 9 core/modules/config_translation/src/FormElement/Textarea.php
  2. 9 core/lib/Drupal/Core/Render/Element/Textarea.php
  3. 8.9.x core/modules/config_translation/src/FormElement/Textarea.php
  4. 8.9.x core/lib/Drupal/Core/Render/Element/Textarea.php
  5. 10 core/modules/config_translation/src/FormElement/Textarea.php
  6. 10 core/lib/Drupal/Core/Render/Element/Textarea.php

Namespace

Drupal\config_translation\FormElement

File

core/modules/config_translation/src/FormElement/Textarea.php

View source
<?php

namespace Drupal\config_translation\FormElement;

use Drupal\Core\Language\LanguageInterface;

/**
 * Defines the textarea element for the configuration translation interface.
 */
class Textarea extends FormElementBase {
    
    /**
     * {@inheritdoc}
     */
    public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
        // Estimate a comfortable size of the input textarea.
        if (is_string($translation_config)) {
            $rows_words = ceil(str_word_count($translation_config) / 5);
            $rows_newlines = substr_count($translation_config, "\n") + 1;
            $rows = max($rows_words, $rows_newlines);
        }
        return [
            '#type' => 'textarea',
            '#rows' => $rows ?? 1,
        ] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
    }

}

Classes

Title Deprecated Summary
Textarea Defines the textarea element for the configuration translation interface.

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