Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow text-columns to read a nested array value #14998

Merged

Conversation

aSeriousDeveloper
Copy link
Contributor

@aSeriousDeveloper aSeriousDeveloper commented Dec 4, 2024

Description

When a Filament Text column reads a JSON attribute which contains a nested array, it throws an Array to string conversion exception.

I tracked down the issue to occuring in resources/views/columns/text-column.blade.php, where the arrayState is mapped and imploded. It goes through the given array and attempts to grab the value of each item. This works fine for single level arrays, as each value will be something stringable.

However, if one of the values was an array (such as storing a list of integers), then the implode fails.

There is already a check for Filament Enums with Labels for the text column, and collections can be coerced into strings. This PR adds an additional check for if the value being mapped for implosion is an array and if so, then encode it into json. Additionally, it adds a return type to the closure to enforce that the map returns a nullable string.

Visual changes

Short example of data:

image

Before the Fix

image

After the Fix

Screenshot 2024-12-04 114039

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@danharrin danharrin added the bug Something isn't working label Dec 4, 2024
@danharrin danharrin added this to the v3 milestone Dec 4, 2024
@danharrin danharrin merged commit 6f440fe into filamentphp:3.x Dec 4, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants