0
votes

I'm new to CakePHP and have a question about this controller:

function showmy($userid) {

    return $this->Voucher->find('all', array('conditions' => array('Voucher.user_id' => $userid)));

}   

public function index() {
    $this->Voucher->recursive = 0;
    $userid = $this->Session->read('Auth.User.id');
    $this->set('vouchers', $this->showmy($userid ));
}

I want all the Voucher with user_id by the loged in user.

It works, but i get many errors like :

 Warning (2): array_filter() expects parameter 1 to be array, null given     [CORE\Cake\View\Helper\PaginatorHelper.php, line 419]

Maybe someone with more experienced could give me some advice!

Thanks, Julius

3
Interesting. What does your paginator code look like in the view? Since recently we do get the same errors on our servers.. Couldn't find the issue though, yet. You are also using Cake2.3.8?mark
I opened a ticket - maybe this works for you too? github.com/cakephp/cakephp/pull/1495mark

3 Answers

0
votes

I think you need to use PaginatorComponent::paginate() to be able to use the PaginatorHelper in your view. More info in the manual.

0
votes

You must declare $paginate array in you controller for the pagination

public $paginate = array( 'limit' => 25, 'order' => array( 'Post.title' => 'asc' ) );

paginate => array

0
votes
public function index() {
        $this->Voucher->recursive = 0;
        $userid = $this->Session->read('Auth.User.id');
        $this->Paginator->settings = array(
                    array('conditions' => array('Voucher.user_id' => $userid))
                );

        $this->set('vouchers', $this->Paginator->paginate('Voucher'));
    }