I want to create a pagination sort link on a virtual field/entity property in CakePHP 3.0.
In CakePHP 2.x I used to create a virtual field, and then create a paginat
Set your default sort order to be the same as your virtual field:
public $paginate = [
'order' => [
'first_name' => 'ASC',
'last_name' => 'ASC',
]
];
Then just add the following to your View to prevent the paginator from overriding the default order unless specified by the user:
if (empty($_GET['direction'])) { $this->Paginator->options(['url' => ['direction' => null, 'sort' => null]]); }