Commit c6e469e9 authored by webchick's avatar webchick
Browse files

Issue #2152201 by Salah Messaoud, Manuel Garcia, steveoliver, joelpittet,...

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
parent 2516dc30
...@@ -1293,29 +1293,30 @@ function form_pre_render_checkbox($element) { ...@@ -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: * An associative array containing:
* - element: An associative array containing the properties of the element. * - element: An associative array containing the properties of the element.
* Properties used: #children, #attributes. * Properties used: #children, #attributes.
*
* @ingroup themeable
*/ */
function theme_checkboxes($variables) { function template_preprocess_checkboxes(&$variables) {
$element = $variables['element']; $element = $variables['element'];
$attributes = array(); $variables['attributes'] = array();
if (isset($element['#id'])) { 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'])) { 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'])) { 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'];
} }
/** /**
......
...@@ -2732,6 +2732,7 @@ function drupal_common_theme() { ...@@ -2732,6 +2732,7 @@ function drupal_common_theme() {
), ),
'checkboxes' => array( 'checkboxes' => array(
'render element' => 'element', 'render element' => 'element',
'template' => 'checkboxes',
), ),
'form' => array( 'form' => array(
'render element' => 'element', 'render element' => 'element',
......
{#
/**
* @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>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment