From 3ac7239af2f58601283575f5f80b271a63396462 Mon Sep 17 00:00:00 2001 From: Eremin Mikhail Date: Tue, 25 May 2021 09:16:04 +0500 Subject: [PATCH] Fix order models --- components/Crud.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/Crud.php b/components/Crud.php index 22f71e2..c35bb9d 100644 --- a/components/Crud.php +++ b/components/Crud.php @@ -127,13 +127,12 @@ public function getDataProvider($filterParams = true, $pagination = false, $rela 'class' => 'ereminmdev\yii2\crud\components\Pagination', 'storeKey' => basename($modelClass) . '-per-page', ], - 'sort' => [ - 'defaultOrder' => [ - 'id' => SORT_DESC, - ], - ], ]); + if (!empty($dataProvider->sort->getAttributeOrders())) { + $dataProvider->query->orderBy([]); + } + /** @var ActiveQuery $query */ $query = $dataProvider->query;