Skip to content

Commit de781d6

Browse files
authored
Merge pull request #247 from bscheshirwork/accept-traversable
add \Traversable support
2 parents 78c300e + 30d5d16 commit de781d6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Yii2 multiple input change log
33

44
2.18.0 (in development)
55
=======================
6+
- #246 accept `\Traversable` in model attribute for `yield` compatibility (bscheshirwork)
67

78
2.17.0
89
======

src/MultipleInput.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ protected function initData()
254254
return;
255255
}
256256

257-
foreach ((array) $data as $index => $value) {
257+
if (!($data instanceof \Traversable)) {
258+
$data = (array) $data;
259+
}
260+
261+
foreach ($data as $index => $value) {
258262
$this->data[$index] = $value;
259263
}
260264
}

0 commit comments

Comments
 (0)