Skip to content

Commit 5473a1b

Browse files
author
Ivan Salnikov
committed
add key support
1 parent cfa1f44 commit 5473a1b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Yii2 multiple input change log
55
---------------------
66

77
- Enh: increased default value for the property `limit`
8+
- Added support of associative array in data
89

910
1.2.16
1011
------
@@ -142,4 +143,4 @@ Yii2 multiple input change log
142143
1.0.0
143144
-----
144145

145-
first stable release
146+
first stable release

src/renderers/TableRenderer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ protected function renderBody()
117117
if ($this->min === $this->limit && $cnt < $this->limit) {
118118
$cnt = $this->limit;
119119
}
120+
$keys = array_keys($this->data);
120121
for ($i = 0; $i < $cnt; $i++) {
121-
$item = ArrayHelper::getValue($this->data, $i, null);
122-
$rows[] = $this->renderRowContent($i, $item);
122+
$key = ArrayHelper::getValue($keys, $i, $i);
123+
$item = ArrayHelper::getValue($this->data, $key, null);
124+
$rows[] = $this->renderRowContent($key, $item);
123125
}
124126
} elseif ($this->min > 0) {
125127
for ($i = 0; $i < $this->min; $i++) {

0 commit comments

Comments
 (0)