diff --git a/core/modules/views/templates/views-view-table.tpl.php b/core/modules/views/templates/views-view-table.tpl.php index 4d44d42..d60afa6 100644 --- a/core/modules/views/templates/views-view-table.tpl.php +++ b/core/modules/views/templates/views-view-table.tpl.php @@ -6,14 +6,14 @@ * * - $title : The title of this group of rows. May be empty. * - $header: An array of header labels keyed by field id. - * - $header_classes: An array of header classes keyed by field id. + * - $header_classes: An array of header attributes keyed by field id. * - $fields: An array of CSS IDs to use for each field id. * - $classes: A class or classes to apply to the table, based on settings. * - $row_classes: An array of classes to apply to each row, indexed by row * number. This matches the index in $rows. * - $rows: An array of row items. Each row is an array of content. * $rows are keyed by row number, fields within rows are keyed by field ID. - * - $field_classes: An array of classes to apply to each field, indexed by + * - $field_classes: An array of attributes to apply to each field, indexed by * field id, then row number. This matches the index in $rows. * @ingroup views_templates */ @@ -27,7 +27,7 @@ $label): ?> - scope="col"> + > diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 4178bac..8000176 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -457,6 +457,7 @@ function template_preprocess_views_view_table(&$vars) { // Store rows so that they may be used by further preprocess functions. $result = $vars['result'] = $vars['rows']; $vars['rows'] = array(); + // @todo Remove field_classes to field_attributes. $vars['field_classes'] = array(); $vars['header'] = array(); @@ -517,6 +518,7 @@ function template_preprocess_views_view_table(&$vars) { } // Set up the header label class. + // @todo Rename to header_attributes. $vars['header_classes'][$field] = array(); if ($fields[$field]->options['element_default_classes']) { $vars['header_classes'][$field]['class'][] = 'views-field'; @@ -543,6 +545,8 @@ function template_preprocess_views_view_table(&$vars) { if ($element_label_type) { $vars['header'][$field] = '<' . $element_label_type . '>' . $vars['header'][$field] . ''; } + // Improves accessibility of complex tables. + $vars['header_classes'][$field]['id'] = drupal_html_id('view-' . $field . '-table-column'); } } @@ -570,6 +574,11 @@ function template_preprocess_views_view_table(&$vars) { $vars['field_classes'][$field][$num]['class'][] = $options['info'][$field]['responsive']; } + // Improves accessibility of complex tables. + if (isset($vars['header_classes'][$field]['id'])) { + $vars['field_classes'][$field][$num]['headers'] = array($vars['header_classes'][$field]['id']); + } + if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) { $field_output = $handler->get_field($num, $field); $element_type = $fields[$field]->element_type(TRUE, TRUE);