Permalink
Browse files

Fixes #1437: Added ListView::viewParams.

  • Loading branch information...
qiangxue committed Dec 5, 2013
1 parent 4b2659a commit 858c031d0c64750c8927feca07f7ad25f547e4e7
Showing with 7 additions and 2 deletions.
  1. +7 −2 framework/yii/widgets/ListView.php
@@ -43,6 +43,11 @@ class ListView extends BaseListView
* ~~~
*/
public $itemView;
+ /**
+ * @var array additional parameters to be passed to [[itemView]] when it is being rendered.
+ * This property is used only when [[itemView]] is a string representing a view name.
+ */
+ public $viewParams = [];
/**
* @var string the HTML code to be displayed between any two consecutive items.
*/
@@ -76,12 +81,12 @@ public function renderItem($model, $key, $index)
if ($this->itemView === null) {
$content = $key;
} elseif (is_string($this->itemView)) {
- $content = $this->getView()->render($this->itemView, [
+ $content = $this->getView()->render($this->itemView, array_merge([
'model' => $model,
'key' => $key,
'index' => $index,
'widget' => $this,
- ]);
+ ], $this->viewParams));
} else {
$content = call_user_func($this->itemView, $model, $key, $index, $this);
}

0 comments on commit 858c031

Please sign in to comment.