class Textarea
Same name in this branch
- 10 core/lib/Drupal/Core/Render/Element/Textarea.php \Drupal\Core\Render\Element\Textarea
Same name in other branches
- 9 core/modules/config_translation/src/FormElement/Textarea.php \Drupal\config_translation\FormElement\Textarea
- 9 core/lib/Drupal/Core/Render/Element/Textarea.php \Drupal\Core\Render\Element\Textarea
- 8.9.x core/modules/config_translation/src/FormElement/Textarea.php \Drupal\config_translation\FormElement\Textarea
- 8.9.x core/lib/Drupal/Core/Render/Element/Textarea.php \Drupal\Core\Render\Element\Textarea
- 11.x core/modules/config_translation/src/FormElement/Textarea.php \Drupal\config_translation\FormElement\Textarea
- 11.x core/lib/Drupal/Core/Render/Element/Textarea.php \Drupal\Core\Render\Element\Textarea
Defines the textarea element for the configuration translation interface.
Hierarchy
- class \Drupal\config_translation\FormElement\FormElementBase implements \Drupal\config_translation\FormElement\ElementInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\config_translation\FormElement\Textarea extends \Drupal\config_translation\FormElement\FormElementBase
Expanded class hierarchy of Textarea
16 string references to 'Textarea'
- ckeditor5_form_filter_format_form_alter in core/
modules/ ckeditor5/ ckeditor5.module - Implements hook_form_FORM_ID_alter().
- ClaroPreRender::textFormat in core/
themes/ claro/ src/ ClaroPreRender.php - Prerender callback for text_format elements.
- ConfigTranslationUiTestBase::assertDisabledTextarea in core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiTestBase.php - Asserts that a textarea with a given ID has been disabled from editing.
- ContentTranslationHandler::addTranslatabilityClue in core/
modules/ content_translation/ src/ ContentTranslationHandler.php - Adds a clue about the form element translatability.
- ElementTest::testPlaceHolderText in core/
modules/ system/ tests/ src/ Functional/ Form/ ElementTest.php - Tests placeholder text for elements that support placeholders.
File
-
core/
modules/ config_translation/ src/ FormElement/ Textarea.php, line 10
Namespace
Drupal\config_translation\FormElementView source
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);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
FormElementBase::$definition | protected | property | The data definition of the element this form element is for. | ||
FormElementBase::$element | protected | property | The schema element this form is for. | ||
FormElementBase::create | public static | function | Creates a form element instance from a schema definition. | Overrides ElementInterface::create | |
FormElementBase::getSourceElement | protected | function | Returns the source element for a given configuration definition. | 2 | |
FormElementBase::getTranslationBuild | public | function | Builds a render array containing the source and translation form elements. | Overrides ElementInterface::getTranslationBuild | |
FormElementBase::setConfig | public | function | Sets configuration based on a nested form value array. | Overrides ElementInterface::setConfig | 1 |
FormElementBase::__construct | public | function | Constructs a FormElementBase. | ||
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | ||
Textarea::getTranslationElement | public | function | Returns the translation form element for a given configuration definition. | Overrides FormElementBase::getTranslationElement |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.