I have a Posts
table with Translate
behavior and I want to sort it by title on the table at index view. I can't sort by the fields that are translated because the field's don't actually exist on the database. They exist on the i18n
table.
This, as I explained above, doesn't work:
$this->Paginator->sort('title');
$this->Paginator->sort('Posts_title_translation.content');
So, what I should do? What am I missing?
Many Thanks!
The second variant should work once the field is being whitelisted, which is generally necessary for associations to be used for sorting:
Note that with the whitelist in place, you will have to add all other fields of your
Posts
table that need to be used for sorting too!See also Cookbook > ... Components > Pagination > Control which Fields Used for Ordering