Commit 25b466d2 by Qiang Xue

Fixes #2083: make sure keys of object type work with ActionColumn, GridView, etc.

parent d445ab9d
...@@ -72,8 +72,7 @@ class QueryBuilder extends Object ...@@ -72,8 +72,7 @@ class QueryBuilder extends Object
if ($from === null && $query instanceof ActiveQuery) { if ($from === null && $query instanceof ActiveQuery) {
/** @var ActiveRecord $modelClass */ /** @var ActiveRecord $modelClass */
$modelClass = $query->modelClass; $modelClass = $query->modelClass;
$tableName = $modelClass::indexName(); $from = [$modelClass::indexName()];
$from = [$tableName];
} }
$clauses = [ $clauses = [
......
...@@ -123,7 +123,7 @@ class ActionColumn extends Column ...@@ -123,7 +123,7 @@ class ActionColumn extends Column
if ($this->urlCreator instanceof Closure) { if ($this->urlCreator instanceof Closure) {
return call_user_func($this->urlCreator, $action, $model, $key, $index); return call_user_func($this->urlCreator, $action, $model, $key, $index);
} else { } else {
$params = is_array($key) ? $key : ['id' => $key]; $params = is_array($key) ? $key : ['id' => (string)$key];
$route = $this->controller ? $this->controller . '/' . $action : $action; $route = $this->controller ? $this->controller . '/' . $action : $action;
return Yii::$app->controller->createUrl($route, $params); return Yii::$app->controller->createUrl($route, $params);
} }
......
...@@ -379,7 +379,7 @@ class GridView extends BaseListView ...@@ -379,7 +379,7 @@ class GridView extends BaseListView
} else { } else {
$options = $this->rowOptions; $options = $this->rowOptions;
} }
$options['data-key'] = is_array($key) ? json_encode($key) : $key; $options['data-key'] = is_array($key) ? json_encode($key) : (string)$key;
return Html::tag('tr', implode('', $cells), $options); return Html::tag('tr', implode('', $cells), $options);
} }
......
...@@ -98,7 +98,7 @@ class ListView extends BaseListView ...@@ -98,7 +98,7 @@ class ListView extends BaseListView
$options = $this->itemOptions; $options = $this->itemOptions;
$tag = ArrayHelper::remove($options, 'tag', 'div'); $tag = ArrayHelper::remove($options, 'tag', 'div');
if ($tag !== false) { if ($tag !== false) {
$options['data-key'] = is_array($key) ? json_encode($key) : $key; $options['data-key'] = is_array($key) ? json_encode($key) : (string)$key;
return Html::tag($tag, $content, $options); return Html::tag($tag, $content, $options);
} else { } else {
return $content; return $content;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment