I would like to sort data within a view table, the data comes from four different tables that are associated with hasOne relationship.
EER used as example:
The action code:
public function index()
{
$this->paginate = [
'limit' => 15,
'contain' => [
'Addresses',
'Emails',
'Phones'
],
'sortWhitelist' => [
'id',
'name',
'Addresses.street',
'Emails.address',
'Phones.number'
]
];
$this->set('users', $this->paginate('Users'));
$this->set('_serialize', ['users']);
}
The relationships as follow:
$this->hasOne('Addresses')
->setForeignKey('user_id')
->setStrategy('select')
->setDependent(true);
$this->hasOne('Emails')
->setForeignKey('user_id')
->setStrategy('select')
->setDependent(true);
$this->hasOne('Phones')
->setForeignKey('user_id')
->setStrategy('select')
->setDependent(true);
This is my sort link:
<?= $this->Paginator->sort('Emails.address', h('E-Mail')) ?>
Problem: Can’t sort any association fields…