diff --git a/framework/yii/data/ActiveDataProvider.php b/framework/yii/data/ActiveDataProvider.php index 0b3fc4a..6625bf5 100644 --- a/framework/yii/data/ActiveDataProvider.php +++ b/framework/yii/data/ActiveDataProvider.php @@ -138,9 +138,9 @@ class ActiveDataProvider extends BaseDataProvider foreach ($models as $model) { $kk = []; foreach ($pks as $pk) { - $kk[] = $model[$pk]; + $kk[$pk] = $model[$pk]; } - $keys[] = json_encode($kk); + $keys[] = $kk; } } return $keys; diff --git a/framework/yii/grid/GridView.php b/framework/yii/grid/GridView.php index de99a18..2510b83 100644 --- a/framework/yii/grid/GridView.php +++ b/framework/yii/grid/GridView.php @@ -373,7 +373,7 @@ class GridView extends BaseListView } else { $options = $this->rowOptions; } - $options['data-key'] = $key; + $options['data-key'] = is_array($key) ? json_encode($key) : $key; return Html::tag('tr', implode('', $cells), $options); } diff --git a/framework/yii/widgets/ListView.php b/framework/yii/widgets/ListView.php index ad13420..11d638c 100644 --- a/framework/yii/widgets/ListView.php +++ b/framework/yii/widgets/ListView.php @@ -88,7 +88,7 @@ class ListView extends BaseListView $options = $this->itemOptions; $tag = ArrayHelper::remove($options, 'tag', 'div'); if ($tag !== false) { - $options['data-key'] = $key; + $options['data-key'] = is_array($key) ? json_encode($key) : $key; return Html::tag($tag, $content, $options); } else { return $content;