summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-04-16 03:52:59 (GMT)
committerwebchick2014-04-16 03:52:59 (GMT)
commitc6e469e9db5fa8e6a78ac06d2df9f772129910fa (patch)
treef35bfaece903ce2e70580b10695220ec9c6a1727
parent2516dc309dba9454a5576373b9393c0e088ebd28 (diff)
Issue #2152201 by Salah Messaoud, Manuel Garcia, steveoliver, joelpittet, burgerboydaddy, katy5289, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_checkboxes() to Twig
-rw-r--r--core/includes/form.inc23
-rw-r--r--core/includes/theme.inc1
-rw-r--r--core/modules/system/templates/checkboxes.html.twig17
3 files changed, 30 insertions, 11 deletions
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 54feee0..bd6d352 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -1293,29 +1293,30 @@ function form_pre_render_checkbox($element) {
}
/**
- * Returns HTML for a set of checkbox form elements.
+ * Prepares variables for checkboxes templates.
*
- * @param $variables
+ * Default template: checkboxes.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #children, #attributes.
- *
- * @ingroup themeable
*/
-function theme_checkboxes($variables) {
+function template_preprocess_checkboxes(&$variables) {
$element = $variables['element'];
- $attributes = array();
+ $variables['attributes'] = array();
if (isset($element['#id'])) {
- $attributes['id'] = $element['#id'];
+ $variables['attributes']['id'] = $element['#id'];
}
- $attributes['class'][] = 'form-checkboxes';
+ $variables['attributes']['class'] = array();
+ $variables['attributes']['class'][] = 'form-checkboxes';
if (!empty($element['#attributes']['class'])) {
- $attributes['class'] = array_merge($attributes['class'], $element['#attributes']['class']);
+ $variables['attributes']['class'] = array_merge($variables['attributes']['class'], $element['#attributes']['class']);
}
if (isset($element['#attributes']['title'])) {
- $attributes['title'] = $element['#attributes']['title'];
+ $variables['attributes']['title'] = $element['#attributes']['title'];
}
- return '<div' . new Attribute($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
+ $variables['children'] = $element['#children'];
}
/**
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 52ce316..6909403 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2732,6 +2732,7 @@ function drupal_common_theme() {
),
'checkboxes' => array(
'render element' => 'element',
+ 'template' => 'checkboxes',
),
'form' => array(
'render element' => 'element',
diff --git a/core/modules/system/templates/checkboxes.html.twig b/core/modules/system/templates/checkboxes.html.twig
new file mode 100644
index 0000000..00384d3
--- /dev/null
+++ b/core/modules/system/templates/checkboxes.html.twig
@@ -0,0 +1,17 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a 'checkboxes' #type form element.
+ *
+ * Available variables
+ * - attributes: A list of HTML attributes for the wrapper element.
+ * - children: The rendered checkboxes.
+ *
+ * @see template_preprocess_checkboxes()
+ *
+ * @ingroup themeable
+ */
+ @todo: remove this file once http://drupal.org/node/1819284 is resolved.
+ This is identical to core/modules/system/templates/container.html.twig
+#}
+<div{{ attributes }}>{{ children }}</div>