- Issue created by @wdmartin
- 🇨🇦Canada Jaypan
I have done some debugging and determined what is happening.
The Twig template states:
tag: The HTML tag name to use; either 'th' or 'td'.
From within the context of the Twig template, this is correct. However, the template does not document how to set this variable.
In theme, inc. I can see that the tag type is set here: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/includes/them...
With the$is_header
value being set here: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/includes/them...So, to set a table cell to use a TH tag, the
header
attribute for the cell must be set. Here is a simple example:$table = [ '#theme' => 'table', '#rows' => [ [ [ 'data' => 'Header cell', // Setting header to TRUE will cause this cell // to be a <th/> rather than the default <td/>. 'header' => TRUE, ], [ 'data' => 'Normal cell', ], ], ], ];
Maybe an update to the table.html.twig documentation to indicate how to set a table cell as a header, would be beneficial to developers.
- First commit to issue fork.
Utkarsh_33 → changed the visibility of the branch 3437166-rendering-engine-disregards to hidden.
- Merge request !8049Added comment in docs explaining how to use a cell as header in a table → (Closed) created by utkarsh_33
- Status changed to Needs review
7 months ago 11:31am 13 May 2024 Updated the docs stating the use of header flag to identify whether a cell can be used a
- Status changed to RTBC
7 months ago 2:13pm 13 May 2024 - 🇺🇸United States smustgrave
Updated the title to more lineup with the solution but seems straight forward.
- Status changed to Needs work
7 months ago 4:03am 14 May 2024 - 🇨🇦Canada Jaypan
The updated documentation listed the
header
attribute as a child of a header cell, but it is not. It is a sibling todata</data>. Also, there are multiple instances of <code>table.html.twig
in core, and each instance needs to be updated. - Status changed to Needs review
7 months ago 6:05am 14 May 2024 - Status changed to Needs work
7 months ago 5:01pm 19 May 2024 - Status changed to Needs review
7 months ago 6:37am 22 May 2024 - 🇨🇦Canada Jaypan
'header' is an key of the 'cells' array, so I think the documentation should set it as a child of that array.
- Status changed to RTBC
7 months ago 5:40pm 29 May 2024 - 🇺🇸United States smustgrave
Feedback appears to be addressed. Thanks @Utkarsh_33 for updating that target
- 🇫🇷France nod_ Lille
Can someone update the comment so that it wraps at 80 chars? after that it's good to go.
- Status changed to Needs work
7 months ago 8:09pm 29 May 2024 - Status changed to RTBC
7 months ago 9:58pm 29 May 2024 - Status changed to Fixed
7 months ago 10:59pm 29 May 2024 - 🇫🇷France nod_ Lille
Committed and pushed 8778ac1801 to 11.x and 8a300d4337 to 11.0.x and 34abc72b52 to 10.4.x and 3923915994 to 10.3.x. Thanks!
Automatically closed - issue fixed for 2 weeks with no activity.