0
votes

I am faced a new issues regarding CakePHP 2.6.X and pagination; I've never had this issue before and it only happens when attempting to use $this->Paginator->sort(...) in a view.

$this->Paginator->sort('Page.id', 'ID', array('model' => 'Page'));

I've done the normal setup of the pagination object in the controller

$this->Paginator->settings = array(
    'contain' => false,
    'group' => 'Page.id',
    'order' => 'Page.name ASC',
    'limit' => 20
);
$results = $this->Paginator->paginate('Page');

I am getting this in the view file

Warning (2): array_filter() expects parameter 1 to be array, null given [CORE/Cake/View/Helper/PaginatorHelper.php, line 435] Warning (2): array_merge() [function.array-merge]: Argument #1 is not an array [CORE/Cake/View/Helper/PaginatorHelper.php, line 435]

Upon tracking the issue it stems from the params function on line 126, on line 131 it is returning null because request->params['paging'] is null.

if (!isset($this->request->params['paging']) || empty($this->request->params['paging'][$model])) {
    return null;
}

With the above explained, why is request->params['paging'] null? Shouldn't it be populated with information as it is in other sections? Is the sort function broken or am I missing something? Any help would be greatly appreciated.

1

1 Answers

0
votes

Have you tried removing the $options parameter? Not sure you need to specify the model if you already do this in the key.

$this->Paginator->sort('Page.id', 'ID');