Skip to content

Conversation

@olipayne
Copy link

@olipayne olipayne commented Jan 31, 2026

Fixes #19152

Problem

When using an HtmlString as a ColumnGroup label (which is allowed by the type signature), PHP throws an error:

Cannot access offset of type Illuminate\Support\HtmlString on array

This happens because the code was trying to use the HtmlString object directly as an array key, but PHP only allows strings or integers as array keys.

Solution

I used e() instead of a (string) cast to match the existing pattern in the codebase. In HasColumnManager::mapTableColumnGroupToArray(), the same conversion is already done with e():

Testing

Added a test case that reproduces the bug and verifies the fix. Without the fix, the test fails with the exact error from the issue. With the fix, all tests pass.

✓ it can use HtmlString as label
Copilot AI review requested due to automatic review settings January 31, 2026 14:03
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Jan 31, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where using an HtmlString as a ColumnGroup label causes a PHP error, even though the type signature allows it. The fix converts the label to a string using e() before using it as an array key, matching the existing pattern used elsewhere in the codebase.

Changes:

  • Modified HasColumns::pushColumns() to convert ColumnGroup labels to strings before using them as array keys
  • Added a test case that verifies HtmlString can be used as a ColumnGroup label

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/tables/src/Table/Concerns/HasColumns.php Fixed bug by converting label to string with e() before using as array key
tests/src/Tables/Columns/ColumnGroupTest.php Added test case and test component class to verify HtmlString labels work correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danharrin danharrin added the bug Something isn't working label Jan 31, 2026
@danharrin danharrin added this to the v4 milestone Jan 31, 2026
@danharrin danharrin requested a review from archilex January 31, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

3 participants