diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index afb159902b9956b74bef8a1edc1b3898086b60fb..671b709c9301bb606465d9775fbd4e51dac6784d 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -736,8 +736,36 @@ function uw_fdsu_theme_resp_preprocess_details(&$variables) { } else { + // If there is an element, process it. + if (isset($variables['element'])) { + + // Step through each of the indexes and ensure that we + // have an actual element, which means it will be an array. + foreach ($variables['element'] as $index => $value) { + + // If this is an array, then we have an element to look at. + if (is_array($value)) { + + // One more check to ensure that we have an element. + if (isset($variables['element'][$index]['#type'])) { + + // Get the id based on where the id is stored, either it + // is by itself or within the attributes. + if (isset($variables['element'][$index]['#id'])) { + $variables['form_field_id'] = $variables['element'][$index]['#id']; + } + elseif (isset($variables['element'][$index]['#attributes']['id'])) { + $variables['form_field_id'] = $variables['element'][$index]['#attributes']['id']; + } + + // Break out of the loop to save computational time. + break; + } + } + } + } // If there is a data drupal selector use it for form field id. - if (isset($variables['element'][0]['#attributes']['data-drupal-selector'])) { + elseif (isset($variables['element'][0]['#attributes']['data-drupal-selector'])) { $variables['form_field_id'] = $variables['element'][0]['#attributes']['data-drupal-selector']; } }