diff --git a/core/includes/theme.inc b/core/includes/theme.inc index ef49f54..c427167 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1381,6 +1381,7 @@ function template_preprocess_table(&$variables) { $variables[$section][$row_key]['cells'][$col_key]['tag'] = $is_header ? 'th' : 'td'; $variables[$section][$row_key]['cells'][$col_key]['attributes'] = new Attribute($cell_attributes); $variables[$section][$row_key]['cells'][$col_key]['content'] = $cell_content; + $variables[$section][$row_key]['cells'][$col_key]['label'] = $variables['header'][$col_key]['content']; } } } diff --git a/core/modules/system/templates/table.html.twig b/core/modules/system/templates/table.html.twig index 9c1cb05..6c301e0 100644 --- a/core/modules/system/templates/table.html.twig +++ b/core/modules/system/templates/table.html.twig @@ -71,7 +71,7 @@ {% for row in rows %} {% for cell in row.cells %} - <{{ cell.tag }}{{ cell.attributes }}> + <{{ cell.tag }}{{ cell.attributes }} data-th="{{ cell.label }}"> {{- cell.content -}} {% endfor %} @@ -84,7 +84,7 @@ {% for row in footer %} {% for cell in row.cells %} - <{{ cell.tag }}{{ cell.attributes }}> + <{{ cell.tag }}{{ cell.attributes }} data-th="{{ cell.label }}"> {{- cell.content -}} {% endfor %} diff --git a/core/modules/views/templates/views-view-table.html.twig b/core/modules/views/templates/views-view-table.html.twig index 6b0b26c..c4db02c 100644 --- a/core/modules/views/templates/views-view-table.html.twig +++ b/core/modules/views/templates/views-view-table.html.twig @@ -61,7 +61,7 @@ {% for row in rows %} {% for column in row.columns %} - + {{ column.content }} {% endfor %} diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index a9bf6f6..c4d7f51 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -552,6 +552,10 @@ function template_preprocess_views_view_table(&$variables) { $column_reference['attributes']['class'][] = 'views-field-' . $variables['fields'][$field]; } + if (!empty($variables['header'][$field]['content'])) { + $column_reference['label'] = $label; + } + if ($classes = $fields[$field]->elementClasses($num)) { $column_reference['attributes']['class'][] = $classes; }