Commit 145778ce authored by alexpott's avatar alexpott

Issue #2322287 by tuutti, lauriii, wheatpenny: Move datetime classes from preprocess to template.

parent d617be8c
......@@ -837,11 +837,6 @@ function template_preprocess_time(&$variables) {
$variables['html'] = FALSE;
}
}
// Add a 'datetime' class.
$variables['attributes']['class'][] = 'datetime';
$variables['attributes'] = new Attribute($variables['attributes']);
}
/**
......@@ -870,7 +865,6 @@ function template_preprocess_datetime_form(&$variables) {
if (!empty($element['#attributes']['class'])) {
$variables['attributes']['class'] = (array) $element['#attributes']['class'];
}
$variables['attributes']['class'][] = 'container-inline';
$variables['content'] = $element;
}
......@@ -896,13 +890,12 @@ function template_preprocess_datetime_wrapper(&$variables) {
$variables['description'] = $element['#description'];
}
$title_attributes = array('class' => array('label'));
$variables['required'] = FALSE;
// For required datetime fields a 'form-required' class is appended to the
// label attributes.
if (!empty($element['#required'])) {
$title_attributes['class'][] = 'form-required';
$variables['required'] = TRUE;
}
$variables['title_attributes'] = new Attribute($title_attributes);
$variables['content'] = $element['#children'];
}
......
......@@ -12,6 +12,6 @@
* @ingroup themeable
*/
#}
<div{{ attributes }}>
<div{{ attributes.addClass('container-inline') }}>
{{ content }}
</div>
......@@ -8,14 +8,21 @@
* - title: The title of the form element.
* - title_attributes: HTML attributes for the title wrapper.
* - description: Description text for the form element.
* - required: An indicator for whether the associated form element is required.
*
* @see template_preprocess_datetime_wrapper()
*
* @ingroup themeable
*/
#}
{%
set title_classes = [
'label',
required ? 'form-required',
]
%}
{% if title %}
<h4{{ title_attributes }}>{{ title }}</h4>
<h4{{ title_attributes.addClass(title_classes) }}>{{ title }}</h4>
{% endif %}
{{ content }}
{% if description %}
......
......@@ -25,4 +25,4 @@
* @see http://www.w3.org/TR/html5-author/the-time-element.html#attr-time-datetime
*/
#}
<time{{ attributes }}>{{ html ? text|raw : text }}</time>
<time{{ attributes.addClass('datetime') }}>{{ html ? text|raw : text }}</time>
Markdown is supported
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