Cakephp: Pagination sorting from foreign fields (fields from associated models)

3.06.2012 | cakephp, PHP

I came across a problem while developing with cakephp 2.0.

Suppose that you have got a Post model and a Category model, and you have a grid, with all posts and the category title they belong to. In order to sort by the category title you will need to do as the following in your view.

echo $this->Paginator->sort('Category.title','labelForTheTableHeader');

Hope that helps anyone
Cheers

Be Sociable, Share!

Responses

Faizan Noor
4.14.2015

Awesome. It helped me. Thanks buddy.

Comments