Problem/Motivation

API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...

The documentation is missing a lot of details. Table seems to support #footer and #caption, which are not listed.

Second, in the example, the table rows are not being added to the #rows element. This could be confusing.

Steps to reproduce

See documentation of in table class in core/lib/Drupal/Core/Render/Element/Table.php

Proposed resolution

Add an example using the #rows element
Add comments to the existing example (without the #rows element) to make it less confusing
Add information about #footer and #caption

Remaining tasks

a. Fix issue summary
b. Review
c. Commit

User interface changes

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

Issue fork drupal-3071143

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

JasonSafro created an issue. See original summary.

jasonsafro’s picture

FYI - The same issues exist on all 8.x versions of the documentation. Since google usually returns the 8.2 version, it would be helpful to update all versions of the 8.x docs.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

larowlan’s picture

Issue tags: +DrupalCon Pittsburgh 2023
smustgrave’s picture

Issue tags: -DrupalCon Pittsburgh 2023 +Pittsburgh 2023
chrisdarke’s picture

Issue tags: -Pittsburgh 2023 +Pittsburgh2023

Migrating Pittsburgh 2023 to Pittsburgh2023 tag for cleanup

danielmme’s picture

I will work on this in Drupal Con

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

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

karimb’s picture

Version: 9.5.x-dev » 11.x-dev

Actually the example is working fine. No need to explicitly declare the #rows property when adding sub-elements (or children) to $form['contacts'] (the main table element). When adding children like $form['contacts'][$i][...] these children will populate the #rows property automatically in preRenderTable(). I added some comments for better understanding.

I also added a new example with the #rows property explicitly declared and added information for #footer and #caption.

(I made a merge request to 11.x)

Hope this help ;)

karimb’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Thank you for working on this @KarimB. Since it seems the original issue summary is different from what you found could you update the issue summary please

anushrikumari’s picture

Issue tags: -Novice

Removing the Novice tag as this issue has been to various contribution events, so keeping this in Novice won't be helpful.

karimb’s picture

Issue summary: View changes

Update the issue summary now that we sure the original example is working fine.

karimb’s picture

Status: Needs work » Needs review
smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work

Added the issue template for guidance, also title doesn't seem to accurately describe the issue. Sorry I should have flagged that earlier in #27, that's my fault.

karimb’s picture

Issue summary: View changes
karimb’s picture

Issue summary: View changes
karimb’s picture

Issue summary: View changes
karimb’s picture

Status: Needs work » Needs review
karimb’s picture

Title: Table Render Array Example Is Incorrect » Table Render Array Documention Is incomplete and confusing
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update

Thanks, this reads well to me so lets see!

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for contributing to better documentation!

I'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions or other work to do.

Thanks to @smustgrave for adding the standard template. That is a big help!

I applied the diff locally and read the changes. What I read is a great improvement! There are lines that are not wrapped correctly, so those will need to be changed. And I have a question which I left in the MR.

Also want to say that this is staying within scope by not changing the 9 usages of the old array syntax in the existing example. It does mean the example is a mixture of old and new array syntax which is unfortunate and another committer my disagree and want that changed here. But there are coding standard issues to fix the old array syntax in @code @endcode examples.

samsylve’s picture

I am working on this issue now as part of a novice contribution workshop at Symetris.

samsylve’s picture

Status: Needs work » Needs review

Fixed wrapping on docblocks.
Fixed array format.

Hope this helps.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems wrapping feedback has been addressed.

larowlan’s picture

Issue credits

  • larowlan committed 734e8cd9 on 10.2.x
    Issue #3071143 by KarimB, samsylve, smustgrave, quietone: Table Render...

  • larowlan committed 3e49eeb7 on 11.x
    Issue #3071143 by KarimB, samsylve, smustgrave, quietone: Table Render...
larowlan’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Checked out locally and verified all the text wrapped at 80 chars.

Committed to 11.x and backported to 10.2.x

Thanks folks 💪

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.