Problem/Motivation

table.html.twig allows setting attributes on the tr elements inside tbody, but not the one inside thead. It would be useful to be able to do this.

Proposed resolution

#header is currently an array of cells. Make it so that if #header contains the key cells, then that is interpreted to be an array of cells and any values in the key row_attributes are added as attributes on the tr.

Remaining tasks

Agree on form of #header. Implement in table.html.twig and template_preprocess_table().

User interface changes

None.

API changes

Additional keys in #header.

Data model changes

None.

Release notes snippet

Issue fork drupal-3421188

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Liam Morland created an issue. See original summary.

shubhamsprasad made their first commit to this issue’s fork.

shubhamsprasad changed the visibility of the branch 3421188-allow-setting-header to hidden.

govind_giri_goswami made their first commit to this issue’s fork.

govind_giri_goswami’s picture

Status: Active » Needs review
govind_giri_goswami’s picture

In both the table.html.twig template and the template_preprocess_table() function, we enabled the addition of attributes to the

elements within the
section based on the header.row_attributes variable.
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests, +Needs change record

Did a small review but seems to be a number of scope changes.

Solution doesn't match the proposed solution

Will need test coverage

If editing a core template they all will have to be updated and CR written.

govind_giri_goswami’s picture

Status: Needs work » Needs review

The modifications to the template_preprocess_table() function enable the setting of attributes for tr elements within the thead of the table. This is achieved by introducing a check for row_attributes within the loop that processes header cells. If row_attributes are present, they are assigned to the respective header cell. Additionally, the row_attributes are merged with existing cell_attributes to ensure preservation of both cell and row attributes.

smustgrave’s picture

Status: Needs review » Needs work

Still seems out of scope changes are still there.

Still missing tests

See just one template is updated and not the others.

No change record.

govind_giri_goswami’s picture

Status: Needs work » Needs review

improved MR

smustgrave’s picture

Status: Needs review » Needs work

#10 still applies

liam morland’s picture

Issue tags: +Needs reroll

rpayanm made their first commit to this issue’s fork.

rpayanm changed the visibility of the branch 3421188-allow-setting-header to hidden.

samit.310@gmail.com changed the visibility of the branch 3421188-allow-setting-header-11.x to hidden.

samit.310@gmail.com changed the visibility of the branch 3421188-allow-setting-header-11.x to active.

liam morland’s picture

There is no need to create a new merge request when doing a reroll. You can use the same branch and use git push --force. GitLab is set to create a tag pointing to the old code so that nothing is lost.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.