M
M
Maxim Timofeev2016-08-11 16:14:15
Yii
Maxim Timofeev, 2016-08-11 16:14:15

How to shuffle models inside activeDataProvider?

How to shuffle models inside activeDataProvider?
That is, on each page (within the page), the models are displayed in a random order.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-08-11
@webinar

I asked myself, I will answer:

$models = $dataProvider->getModels();
shuffle($models);
$dataProvider->setModels($models);

everything turned out to be easier than expected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question