find(list) returns several blank options, find(all) returns correct data but formatted with {

后端 未结 1 1920
日久生厌
日久生厌 2021-01-26 09:16

AvadiariesTable.php

$this->belongsTo(\'AlumnesGrups\', [
        \'foreignKey\' => \'alumnes_grup_id\',
        \'joinType\' => \'INNER         


        
相关标签:
1条回答
  • 2021-01-26 10:13

    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

    0 讨论(0)
提交回复
热议问题