summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-02-04 09:28:23 -0800
committerwebchick2014-02-04 09:28:23 -0800
commitb9de0424f299f7568b02388f518be07d95c1436d (patch)
treec171bff103ad3c157270da86926e284babd185bd
parent4fe6358e4c7a2daee77de664fa8b2f1135b6d72d (diff)
Issue #2152229 by steveoliver, rteijeiro, joelpittet, JeroenT, InternetDevels, michamilz, burgerboydaddy, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_textarea() to Twig
-rw-r--r--core/includes/form.inc21
-rw-r--r--core/includes/theme.inc1
-rw-r--r--core/modules/system/templates/textarea.html.twig16
3 files changed, 27 insertions, 11 deletions
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 034df83..b3cb6dd 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -2576,34 +2576,33 @@ function theme_form($variables) {
}
/**
- * Returns HTML for a textarea form element.
+ * Prepares variables for textarea templates.
*
- * @param $variables
+ * Default template: textarea.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #rows, #cols,
* #placeholder, #required, #attributes, #resizable
*
- * @ingroup themeable
*/
-function theme_textarea($variables) {
+function template_preprocess_textarea(&$variables) {
$element = $variables['element'];
element_set_attributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
_form_set_attributes($element, array('form-textarea'));
-
- $wrapper_attributes = array(
+ $variables['wrapper_attributes'] = new Attribute(array(
'class' => array('form-textarea-wrapper'),
- );
+ ));
// Add resizable behavior.
if (!empty($element['#resizable'])) {
$element['#attributes']['class'][] = 'resize-' . $element['#resizable'];
}
- $output = '<div' . new Attribute($wrapper_attributes) . '>';
- $output .= '<textarea' . new Attribute($element['#attributes']) . '>' . String::checkPlain($element['#value']) . '</textarea>';
- $output .= '</div>';
- return $output;
+ $variables['attributes'] = new Attribute($element['#attributes']);
+
+ $variables['value'] = String::checkPlain($element['#value']);
}
/**
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 9aa2017..3dd8449 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2725,6 +2725,7 @@ function drupal_common_theme() {
),
'textarea' => array(
'render element' => 'element',
+ 'template' => 'textarea',
),
'tableselect' => array(
'render element' => 'element',
diff --git a/core/modules/system/templates/textarea.html.twig b/core/modules/system/templates/textarea.html.twig
new file mode 100644
index 0000000..a12d04d
--- /dev/null
+++ b/core/modules/system/templates/textarea.html.twig
@@ -0,0 +1,16 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a 'textarea' #type form element.
+ *
+ * Available variables
+ * - wrapper_attributes: A list of HTML attributes for the wrapper element.
+ * - attributes: A list of HTML attributes for the textarea element.
+ * - value: The textarea content.
+ *
+ * @see template_preprocess_textarea()
+ *
+ * @ingroup themeable
+ */
+#}
+<div{{ wrapper_attributes }}><textarea{{ attributes }}>{{ value }}</textarea></div>