mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
Fixes #2083: make sure keys of object type work with ActionColumn, GridView, etc.
This commit is contained in:
@ -72,8 +72,7 @@ class QueryBuilder extends Object
|
||||
if ($from === null && $query instanceof ActiveQuery) {
|
||||
/** @var ActiveRecord $modelClass */
|
||||
$modelClass = $query->modelClass;
|
||||
$tableName = $modelClass::indexName();
|
||||
$from = [$tableName];
|
||||
$from = [$modelClass::indexName()];
|
||||
}
|
||||
|
||||
$clauses = [
|
||||
|
||||
@ -123,7 +123,7 @@ class ActionColumn extends Column
|
||||
if ($this->urlCreator instanceof Closure) {
|
||||
return call_user_func($this->urlCreator, $action, $model, $key, $index);
|
||||
} else {
|
||||
$params = is_array($key) ? $key : ['id' => $key];
|
||||
$params = is_array($key) ? $key : ['id' => (string)$key];
|
||||
$route = $this->controller ? $this->controller . '/' . $action : $action;
|
||||
return Yii::$app->controller->createUrl($route, $params);
|
||||
}
|
||||
|
||||
@ -379,7 +379,7 @@ class GridView extends BaseListView
|
||||
} else {
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ class ListView extends BaseListView
|
||||
$options = $this->itemOptions;
|
||||
$tag = ArrayHelper::remove($options, 'tag', 'div');
|
||||
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);
|
||||
} else {
|
||||
return $content;
|
||||
|
||||
Reference in New Issue
Block a user