Issue #3240174 by alexpott, andypost, daffie: \Drupal\config_translation\FormElement\Textarea() can cause deprecations on PHP 8.1
parent
3fc999a87f
commit
2145374d1e
|
@ -14,13 +14,15 @@ class Textarea extends FormElementBase {
|
|||
*/
|
||||
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
// Estimate a comfortable size of the input textarea.
|
||||
$rows_words = ceil(str_word_count($translation_config) / 5);
|
||||
$rows_newlines = substr_count($translation_config, "\n") + 1;
|
||||
$rows = max($rows_words, $rows_newlines);
|
||||
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,
|
||||
'#rows' => $rows ?? 1,
|
||||
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue