Skip to content

Commit

Permalink
Dev: fix survey pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-foster-uk committed Feb 7, 2024
1 parent 650bad5 commit aded0fe
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions application/models/Survey.php
Expand Up @@ -1525,9 +1525,18 @@ public function search($options = [])
if (method_exists(Yii::app()->cache, 'flush')) {
Yii::app()->cache->flush();
}
$pageSizeUser = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
$pageSize = $options['pageSize'] ?? $pageSizeUser;
$currentPage = $options['currentPage'] ?? null;
$pagination = [
'pageSize' => Yii::app()->user->getState(
'pageSize',
Yii::app()->params['defaultPageSize']
)
];
if (isset($options['pageSize'])) {
$pagination['pageSize'] = $options['pageSize'];
}
if (isset($options['currentPage'])) {
$pagination['currentPage'] = $options['currentPage'];
}

$sort = new CSort();
$sort->attributes = array(
Expand Down Expand Up @@ -1653,10 +1662,7 @@ public function search($options = [])
$dataProvider = new CActiveDataProvider('Survey', array(
'sort' => $sort,
'criteria' => $criteria,
'pagination' => array(
'pageSize' => $pageSize,
'currentPage' => $currentPage
),
'pagination' => $pagination,
));

$dataProvider->setTotalItemCount($this->count($criteria));
Expand Down

0 comments on commit aded0fe

Please sign in to comment.