在cakephp3的查询列表中显示自定义字段

Fur*_*ury 1 cakephp cakephp-3.2

我想使用自定义字段创建下拉列表,但我的列表查询将id字段附加到查询中。如何仅显示查询中的选定字段。

$this->loadModel('CardTypes');
$cardTypes = $this->CardTypes->find('list')->select(['code', 'name']);
Run Code Online (Sandbox Code Playgroud)

在我看来

$this->Form->select('card_type_id', $cardTypes, [ 'default' => 'DELTA']);
Run Code Online (Sandbox Code Playgroud)

ari*_*lia 5

参见手册

$cardTypes = $this->CardTypes->->find('list', [
    'keyField' => 'code',
    'valueField' => 'name'
]);
Run Code Online (Sandbox Code Playgroud)