diff --git a/templates/elements/details.html.twig b/templates/elements/details.html.twig index 07ab4915346bf0c83f858afdc397beb1407c77ee..5ccb9c2eaa36a5571f7a1b67fa2d0a6a2aff6e64 100644 --- a/templates/elements/details.html.twig +++ b/templates/elements/details.html.twig @@ -30,7 +30,7 @@ Prefix 'details' class to avoid collision with Modernizr. ] %} <summary{{ summary_attributes.addClass(summary_classes) }}> - <label for="{{ form_field_id }}">{{ title }}</label> + <label{% if form_field_id %} for="{{ form_field_id }}"{% endif %}>{{ title }}</label> </summary> {%- endif -%} <div class="seven-details__wrapper details-wrapper"> diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 05f12bf9ff9b4de225b2b035ca05c4bbb47ea185..77304427a743ff05d9e6087155956f86c31f6652 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -693,11 +693,38 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) { */ function uw_fdsu_theme_resp_preprocess_details(&$variables) { - // Add the form field id to the variables. - // This comes from ISTWCMS-6711, we are - // removing the -collapsible if there is - // one there and using the html id. If there - // is no -collapsible, it will just use the - // html id. - $variables['form_field_id'] = str_replace('-collapsible', '', $variables['attributes']['id']); + // 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']; + } + } }