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 associative array cell content in Table widget #19908

Merged
merged 23 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
83fda4b
Merge pull request #1 from yiisoft/master
rhertogh Jul 30, 2015
5231894
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jan 24, 2020
e388dfc
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jul 16, 2020
6b56e2c
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Aug 20, 2020
1676da7
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Oct 31, 2020
accf01e
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh May 23, 2021
8856e22
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Jun 2, 2021
22f4a41
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Jun 23, 2021
6548c45
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Aug 15, 2021
315bda2
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Sep 13, 2021
3db5c78
Merge branch 'master' of https://github.com/yiisoft/yii2 into master
rhertogh Sep 15, 2021
c164bea
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jan 17, 2022
1b5c680
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh May 16, 2022
91a8582
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jun 13, 2022
c1b3877
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Oct 27, 2022
43b4425
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Apr 10, 2023
bedfa1f
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh May 17, 2023
412399b
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh May 28, 2023
acad979
Merge branch 'master' of https://github.com/yiisoft/yii2
rhertogh Jun 26, 2023
6036621
Merge remote-tracking branch 'origin/master'
rhertogh Jul 21, 2023
fd68494
Fixed rendering of assosative arrays in `\yii\console\widgets\Table`
rhertogh Jul 22, 2023
7d77ab0
Updated readme for #19908 (fix associative array cell content renderi…
rhertogh Jul 22, 2023
acc98a2
Merge branch 'master' into fix_associative_array_in_table_widget
samdark Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Yii Framework 2 Change Log
- Enh #19853: Added support for default value for `\yii\helpers\Console::select()` (rhertogh)
- Bug #19868: Added whitespace sanitation for tests, due to updates in ICU 72 (schmunk42)
- Enh #19884: Added support Enums in Query Builder (sk1t0n)
- Bug #19908: Fix associative array cell content rendering in Table widget (rhertogh)
- Bug #19906: Fixed multiline strings in the `\yii\console\widgets\Table` widget (rhertogh)


Expand Down
6 changes: 5 additions & 1 deletion framework/console/widgets/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@
{
$this->rows = array_map(function($row) {
return array_map(function($value) {
return empty($value) && !is_numeric($value) ? ' ' : $value;
return empty($value) && !is_numeric($value)
? ' '
: (is_array($value)
? array_values($value)
: $value);

Check warning on line 143 in framework/console/widgets/Table.php

View check run for this annotation

Codecov / codecov/patch

framework/console/widgets/Table.php#L139-L143

Added lines #L139 - L143 were not covered by tests
}, array_values($row));
}, $rows);
return $this;
Expand Down
5 changes: 3 additions & 2 deletions tests/framework/console/widgets/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ public function testLists()
╔═══════════════╤═══════════════╤══════════════╗
║ test1 │ test2 │ test3 ║
╟───────────────┼───────────────┼──────────────╢
║ testcontent1 │ testcontent2 │ testcontent3 ║
║ • col1 │ testcontent2 │ testcontent3 ║
║ • col2 │ │ ║
╟───────────────┼───────────────┼──────────────╢
║ testcontent21 │ testcontent22 │ • col1 ║
║ │ │ • col2 ║
Expand All @@ -226,7 +227,7 @@ public function testLists()

$this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3'])
->setRows([
['testcontent1', 'testcontent2', 'testcontent3'],
[['key1' => 'col1', 'key2' => 'col2'], 'testcontent2', 'testcontent3'],
['testcontent21', 'testcontent22', ['col1', 'col2']],
])->setScreenWidth(200)->run()
);
Expand Down
Loading