-
Notifications
You must be signed in to change notification settings - Fork 917
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
ensure table column works with associative arrays too #3387
ensure table column works with associative arrays too #3387
Conversation
@pxpm I tested this, and it's braking the current table. Also, can you give me an example where we can use a field to create an associate array so I can test that part? |
@promatik i tested it and it works AFTER changes how did you save your array and which php version you have ! My PHP version 7.3.9 |
…ith-single-dimension-arrays # Conflicts: # src/resources/views/crud/columns/table.blade.php
If it's non-BC and a SHOULD (not a MUST) then it's a problem for future us. Moving to 4.2.x. Let's focus on the 4.2 launch please, we have more important things to finish. |
The inspection completed: 544 Issues, 80 Patches |
@pxpm this column will soon be moved to Thanks! |
@tabacitu I've done the required changes to make this non-BC and solve the problem we are trying to solve here. So before table would work if:
After it works:
I've removed the need to check for AFAIK nothing breaks, a good and easy way to test is by adding the CRUD::addColumn([
'name' => 'features',
'type' => 'table',
'columns' => ['name' => 'name', 'desc' => 'desc']
]); If you want to test the other scenarios too you can pass them in column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, everything is working and I think this is a non breaking change 🙌
There was only one situation that was not covered by the validations, it was the case the user sent an array of objects, something like;
'value' => function ($entry) {
return [
(object) ['name' => '1', 'desc' => 'a'],
(object) ['name' => '2', 'desc' => 'b'],
];
},
But this can't happen by the normal usage of the field (save/retrieve).
refs: #2635
Problem: Using table column to display a single array of values.
Solution: As is expected by table column, we ensure to provide a multi-dimensional array when developer provide a single array.
If I understood code correctly, only when the field is not casted as array we endup with an object as value because of the
json_decode
, forcingtrue
as a second parameter we ensure anarray
output instead ofobject
.So we migth be able to remove the conditional check for
is_object()
.