diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php index 6d73636..66338fe 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php @@ -19,7 +19,7 @@ class FieldWebTest extends HandlerTestBase { * * @var array */ - public static $testViews = array('test_view', 'test_field_classes', 'test_field_output', 'test_click_sort'); + public static $testViews = array('test_view', 'test_field_attributes', 'test_field_output', 'test_click_sort'); protected $column_map = array( 'views_test_data_name' => 'name', @@ -320,10 +320,10 @@ public function testAlterUrl() { } /** - * Tests the field/label/wrapper classes. + * Tests the field/label/wrapper attributes. */ - public function testFieldClasses() { - $view = views_get_view('test_field_classes'); + public function testFieldAttributes() { + $view = views_get_view('test_field_attributes'); $view->initHandlers(); // Tests whether the default field classes are added. diff --git a/core/modules/views/templates/views-view-table.html.twig b/core/modules/views/templates/views-view-table.html.twig index 2242c0b..9f36339 100644 --- a/core/modules/views/templates/views-view-table.html.twig +++ b/core/modules/views/templates/views-view-table.html.twig @@ -8,7 +8,7 @@ * - class: HTML classes that can be used to style contextually through CSS. * - title : The title of this group of rows. * - header: Header labels. - * - header_classes: HTML classes to apply to each header cell, indexed by + * - header_attributes: HTML attributes to apply to each header cell, indexed by * the header's key. * - caption_needed: Is the caption tag needed. * - caption: The caption for this table. @@ -20,7 +20,7 @@ * - content: Table data content. * - row_classes: HTML classes to apply to each row, indexed by row number. * This matches the index in rows. - * - field_classes: HTML classes to apply to each row, indexed by row number. + * - field_attributes: HTML attributes to apply to each row, indexed by row number. * This matches the index in columns and rows. * * @see template_preprocess_views_view_table() @@ -52,7 +52,7 @@ {% for key, field in header %} - + {{ field }} {% endfor %} @@ -63,7 +63,7 @@ {% for row_count, row in rows %} {% for field, content in row %} - + {{ content }} {% endfor %} diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_attributes.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_attributes.yml new file mode 100644 index 0000000..0bc1c1c --- /dev/null +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_attributes.yml @@ -0,0 +1,34 @@ +base_table: views_test_data +core: '8' +description: '' +status: '1' +display: + default: + display_options: + access: + type: none + cache: + type: none + fields: + id: + id: id + table: views_test_data + field: id + plugin_id: numeric + provider: views_test_data + style: + type: html_list + display_plugin: default + display_title: Master + id: default + position: '0' + page_1: + display_options: + path: test_field_attributes + display_plugin: page + display_title: Page + id: page_1 + position: '0' +label: { } +id: test_field_attributes +tag: '' diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_classes.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_classes.yml deleted file mode 100644 index 4f0a5e2..0000000 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_classes.yml +++ /dev/null @@ -1,34 +0,0 @@ -base_table: views_test_data -core: '8' -description: '' -status: '1' -display: - default: - display_options: - access: - type: none - cache: - type: none - fields: - id: - id: id - table: views_test_data - field: id - plugin_id: numeric - provider: views_test_data - style: - type: html_list - display_plugin: default - display_title: Master - id: default - position: '0' - page_1: - display_options: - path: test_field_classes - display_plugin: page - display_title: Page - id: page_1 - position: '0' -label: { } -id: test_field_classes -tag: '' diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 8b63c8e..6e79f94 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -511,8 +511,7 @@ function template_preprocess_views_view_table(&$variables) { // Store rows so that they may be used by further preprocess functions. $result = $variables['result'] = $variables['rows']; $variables['rows'] = array(); - // @todo Remove field_classes to field_attributes. - $variables['field_classes'] = array(); + $variables['field_attributes'] = array(); $variables['header'] = array(); $options = $view->style_plugin->options; @@ -575,26 +574,26 @@ function template_preprocess_views_view_table(&$variables) { $variables['header'][$field] = l($label, current_path(), $link_options); } - // Set up the header label class. - // @todo Rename to header_attributes. - $variables['header_classes'][$field] = array(); + // Set up the header label attributes. + $variables['header_attributes'][$field] = array(); if ($fields[$field]->options['element_default_classes']) { - $variables['header_classes'][$field]['class'][] = 'views-field'; - $variables['header_classes'][$field]['class'][] = 'views-field-' . $variables['fields'][$field]; + $variables['header_attributes'][$field]['class'][] = 'views-field'; + $variables['header_attributes'][$field]['class'][] = 'views-field-' . $variables['fields'][$field]; + $variables['header_attributes'][$field]['scope'][] = 'col'; } - $variables['header_classes'][$field] = new Attribute($variables['header_classes'][$field]); + $variables['header_attributes'][$field] = new Attribute($variables['header_attributes'][$field]); $class = $fields[$field]->elementLabelClasses(0); if ($class) { - $variables['header_classes'][$field]['class'][] = $class; + $variables['header_attributes'][$field]['class'][] = $class; } - // Add responsive header classes. + // Add responsive header attributes. if (!empty($options['info'][$field]['responsive'])) { - $variables['header_classes'][$field]['class'][] = $options['info'][$field]['responsive']; + $variables['header_attributes'][$field]['class'][] = $options['info'][$field]['responsive']; $responsive = TRUE; } - // Add a CSS align class to each field if one was set. + // Add a CSS align class attribute to each field if one was set. if (!empty($options['info'][$field]['align'])) { - $variables['header_classes'][$field]['class'][] = drupal_clean_css_identifier($options['info'][$field]['align']); + $variables['header_attributes'][$field]['class'][] = drupal_clean_css_identifier($options['info'][$field]['align']); } // Add a header label wrapper if one was selected. if ($variables['header'][$field]) { @@ -603,7 +602,7 @@ function template_preprocess_views_view_table(&$variables) { $variables['header'][$field] = '<' . $element_label_type . '>' . $variables['header'][$field] . ''; } // Improves accessibility of complex tables. - $vars['header_classes'][$field]['id'] = drupal_html_id('view-' . $field . '-table-column'); + $vars['header_attributes'][$field]['id'] = drupal_html_id('view-' . $field . '-table-column'); } } @@ -614,25 +613,25 @@ function template_preprocess_views_view_table(&$variables) { // Render each field into its appropriate column. foreach ($result as $num => $row) { - // Add field classes. - $variables['field_classes'][$field][$num] = array(); + // Add field attributes. + $variables['field_attributes'][$field][$num] = array(); if ($fields[$field]->options['element_default_classes']) { - $variables['field_classes'][$field][$num]['class'][] = 'views-field'; - $variables['field_classes'][$field][$num]['class'][] = 'views-field-' . $variables['fields'][$field]; + $variables['field_attributes'][$field][$num]['class'][] = 'views-field'; + $variables['field_attributes'][$field][$num]['class'][] = 'views-field-' . $variables['fields'][$field]; } - $variables['field_classes'][$field][$num] = new Attribute($variables['field_classes'][$field][$num]); + $variables['field_attributes'][$field][$num] = new Attribute($variables['field_attributes'][$field][$num]); if ($classes = $fields[$field]->elementClasses($num)) { - $variables['field_classes'][$field][$num]['class'][] = $classes; + $variables['field_attributes'][$field][$num]['class'][] = $classes; } // Add responsive header classes. if (!empty($options['info'][$field]['responsive'])) { - $variables['field_classes'][$field][$num]['class'][] = $options['info'][$field]['responsive']; + $variables['field_attributes'][$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 (isset($vars['header_attributes'][$field]['id'])) { + $vars['field_attributes'][$field][$num]['headers'] = array($vars['header_attributes'][$field]['id']); } if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) { @@ -707,7 +706,7 @@ function template_preprocess_views_view_table(&$variables) { $variables['rows'][0][0] = drupal_render($build); $variables['row_classes'][0] = new Attribute(array('class' => 'odd')); // Calculate the amounts of rows with output. - $variables['field_classes'][0][0] = new Attribute(array( + $variables['field_attributes'][0][0] = new Attribute(array( 'colspan' => count($variables['header']), 'class' => 'views-empty', ));