AvadiariesTable.php
$this->belongsTo(\'AlumnesGrups\', [
\'foreignKey\' => \'alumnes_grup_id\',
\'joinType\' => \'INNER
Use find('list')
and use valueField
for the field you want to show and keyField
for its value:
$alumnesGrups = $this->Avadiaries->AlumnesGrups->find('list', [
'keyField' => 'alumne.name',
'valueField' => 'alumne.name'])
->contain(['Alumnes', 'Grups'])
->where(['Grups.id =' => 1])
->order(['Alumnes.name' => 'ASC']);
Check: http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#finding-key-value-pairs