Skip to content
Snippets Groups Projects
Commit 3a7d5b1d authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Merge branch 'feature/ISTWCMS-6711-ebremner-fix-details-label' into '1.1.x'

ISTWCMS-6711: fixing label for details

See merge request !122
parents 6b2b8c82 d4f86cf2
No related branches found
No related tags found
1 merge request!122ISTWCMS-6711: fixing label for details
{#
/**
* @file
* Theme override for a details element.
*
* Available variables
* - attributes: A list of HTML attributes for the details element.
* - errors: (optional) Any errors for this details element, may not be set.
* - title: (optional) The title of the element, may not be set.
* - summary_attributes: A list of HTML attributes for the summary element.
* - description: (optional) The description of the element, may not be set.
* - children: (optional) The children of the element, may not be set.
* - value: (optional) The value of the element, may not be set.
*
* @see template_preprocess_details()
*/
#}
{#
Prefix 'details' class to avoid collision with Modernizr.
@todo Remove prefix after https://www.drupal.org/node/2981732 has been solved.
#}
<details{{ attributes.addClass('seven-details') }}>
{%- if title -%}
{%
set summary_classes = [
'seven-details__summary',
required ? 'js-form-required',
required ? 'form-required',
]
%}
<summary{{ summary_attributes.addClass(summary_classes) }}>
{% if form_field_id %}
<label for="{{ form_field_id }}">{{ title }}</label>
{% else %}
<span>{{ title }}</span>
{% endif %}
</summary>
{%- endif -%}
<div class="seven-details__wrapper details-wrapper">
{% if errors %}
<div class="form-item form-item--error-message">
<strong>{{ errors }}</strong>
</div>
{% endif %}
{%- if description -%}
<div class="seven-details__description">{{ description }}</div>
{%- endif -%}
{%- if children -%}
{{ children }}
{%- endif -%}
{%- if value -%}
{{ value }}
{%- endif -%}
</div>
</details>
...@@ -687,3 +687,44 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) { ...@@ -687,3 +687,44 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) {
} }
} }
} }
/**
* Implements template_preprocess_details().
*/
function uw_fdsu_theme_resp_preprocess_details(&$variables) {
// ISTWCMS-6711: this comes from the label not having the
// correct for in it. So we are going to check if this is
// a better exposed filter and if so then add the correct
// based on the type of exposed filter it is. The date
// filter needs special treatment, since it is using the
// wrapper as the data drupal selector, and we need it to
// use the -value. If it is not a bef, then check if there
// is a data drupal selector and use it as the form field id.
if (
isset($variables['element'][0]['#context']['#plugin_type']) &&
$variables['element'][0]['#context']['#plugin_type'] == 'bef'
) {
// If this is a date picker, then change the form field id
// to use -value instead of -wrapper. If not then just use
// the straight data drupal selector.
if ($variables['element'][0]['#context']['#plugin_id'] == 'bef_datepicker') {
$variables['form_field_id'] = str_replace(
'-wrapper',
'-value',
$variables['element'][0]['#attributes']['data-drupal-selector']
);
}
else {
$variables['form_field_id'] = $variables['element'][0]['#attributes']['data-drupal-selector'];
}
}
else {
// If there is a data drupal selector use it for form field id.
if (isset($variables['element'][0]['#attributes']['data-drupal-selector'])) {
$variables['form_field_id'] = $variables['element'][0]['#attributes']['data-drupal-selector'];
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment