diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index dca3886227c..bce7b6b1f8e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -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) diff --git a/framework/console/widgets/Table.php b/framework/console/widgets/Table.php index 658cf5fd55b..c0ece4d4d89 100644 --- a/framework/console/widgets/Table.php +++ b/framework/console/widgets/Table.php @@ -136,7 +136,11 @@ public function setRows(array $rows) { $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); }, array_values($row)); }, $rows); return $this; diff --git a/tests/framework/console/widgets/TableTest.php b/tests/framework/console/widgets/TableTest.php index b5bf6f2c6dc..796c95ad1d6 100644 --- a/tests/framework/console/widgets/TableTest.php +++ b/tests/framework/console/widgets/TableTest.php @@ -216,7 +216,8 @@ public function testLists() ╔═══════════════╤═══════════════╤══════════════╗ ║ test1 │ test2 │ test3 ║ ╟───────────────┼───────────────┼──────────────╢ -║ testcontent1 │ testcontent2 │ testcontent3 ║ +║ • col1 │ testcontent2 │ testcontent3 ║ +║ • col2 │ │ ║ ╟───────────────┼───────────────┼──────────────╢ ║ testcontent21 │ testcontent22 │ • col1 ║ ║ │ │ • col2 ║ @@ -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() );