When baking an app, you get a view.php able to show the child records related to a parent record:
The child records are not paginated like they are by default in the index.php when baking that template.
How to change the baked controller to get the pagination into effect?
My ‘natural’ thing to do is:
public function view($id = null)
{
$group = $this->paginate($this->Groups->get($id, [
'contain' => ['Individuals'],
]));
$this->set(compact('group'));
}
but CakePHP makes clear that’s not the way to go (and I guess the bake command would deliver this by default?)
The cookbook tries to tell me something (https://book.cakephp.org/4/en/controllers/components/pagination.html#control-which-fields-used-for-ordering), but because my lack of knowledge, can’t implement it in the right way.
StackOverflow has a topic (paginate associated records), it’s several years old, is it THE solution with CakePHP4?
So, how can I get my related records paginated?