T
T
ta42016-02-08 18:47:07
Yii
ta4, 2016-02-08 18:47:07

Two links (up/down) for sorting in Yii2. How to work with yii\data\Sort?

Need to sort output data in Yii2.
There are several tasks that I have not yet figured out how to solve in Yii2.
1) it is necessary that the page has 2 links (the first sorts in descending order, the second, respectively, in ascending order). I get the link using createUrl() , but it works in both directions (ASC, DESC)
2) It is necessary to implement the ability to sort in only one direction, now I did this:

$sort = new Sort([
            'attributes' => [
                'price' => [
                    'desc' => ['price' => SORT_ASC],
                ],
            ],
        ]);

Perhaps there is a better solution. Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question