Thursday, February 20, 2014

Containable with Pagination

Hi All,

I'm having a problem getting Containable behaviour working with the Pagination component. I'm following the suggested code in the manual "Using Containable with Pagination" - http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#using-containable-with-pagination

My code is as follows (SchedulesController.php)

public function show() {

$this->paginate['contain'] = array(
'Assignment' => array(
'AssignmentsStudent' => array(
'School' => array('fields' => array('name')),
'Student' => array('fields' => array('given_name', 'family_name'))
),
'Type' => array('fields' => array('name', 'acronym')),
'fields' => array('theme', 'source')
),
'fields' => array(
'name',
'date'
)
);

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

However running this code gives me the following error

Notice (8): Indirect modification of overloaded property SchedulesController::$paginate has no effect [APP/Controller/SchedulesController.php, line 35]

I have double checked the I have public $actsAs = array('Containable'); in my Schedule.php model file. The output array doesn't contain any of the deep associations and I guess this is because of what the error says "$paginate has no effect".

I have containable working in some other controllers (not with pagination) so I'm fairly confident that my array nesting is ok.... but I could be wrong.

Any assistance would be welcome!


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: