问题
I want to create a dropdown with custom field but my list query append id field into the query. How to show only selected fields in my query.
$this->loadModel('CardTypes');
$cardTypes = $this->CardTypes->find('list')->select(['code', 'name']);
In my view
$this->Form->select('card_type_id', $cardTypes, [ 'default' => 'DELTA']);
回答1:
see the manual
$cardTypes = $this->CardTypes->->find('list', [
'keyField' => 'code',
'valueField' => 'name'
]);
来源:https://stackoverflow.com/questions/38831063/show-custom-field-in-query-list-in-cakephp3