diff --git a/core/includes/form.inc b/core/includes/form.inc index 54feee0952db4e274ec727a8e743589f6ed9c3ac..bd6d35205cdfb63d946bfbc25d71c06d7ffd38a5 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 '' . (!empty($element['#children']) ? $element['#children'] : '') . ''; + $variables['children'] = $element['#children']; } /** diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 52ce3160165d2ada7e50c3f88030862f40f141df..69094036665662d2b96fb91436d88411b11fc457 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 0000000000000000000000000000000000000000..00384d3b73cde67527f9954a3a6a041eab93767e --- /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 +#} +{{ children }}