function FormPreprocess::preprocessTextarea
Prepares variables for textarea templates.
Default template: textarea.html.twig.
Parameters
array $variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #title, #value, #description, #rows, #cols, #maxlength, #placeholder, #required, #attributes, #resizable.
File
-
core/
lib/ Drupal/ Core/ Form/ FormPreprocess.php, line 236
Class
- FormPreprocess
- Initial preprocess callbacks for the form system.
Namespace
Drupal\Core\FormCode
public function preprocessTextarea(array &$variables) : void {
$element = $variables['element'];
$attributes = [
'id',
'name',
'rows',
'cols',
'maxlength',
'placeholder',
];
Element::setAttributes($element, $attributes);
RenderElementBase::setAttributes($element, [
'form-textarea',
]);
$variables['wrapper_attributes'] = new Attribute();
$variables['attributes'] = new Attribute($element['#attributes']);
$variables['value'] = $element['#value'];
$resizable = !empty($element['#resizable']) ? $element['#resizable'] : NULL;
$variables['resizable'] = $resizable;
if ($resizable) {
$variables['attributes']->addClass('resize-' . $resizable);
}
$variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.