Show custom field in query list in cakephp3

守給你的承諾、 提交于 2019-12-23 02:17:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!