Cakephp数据检索只获得ID

时间:2013-12-10 07:20:49

标签: cakephp

我当前正在检索数据并设置为视图以填充输入选择字段,虽然我发现名称只显示选择字段中的ID。这是代码

         // retrieve new lead list
     $arrList = $this->NewLead->find('list', array('order' => 'newlead_name'));          

     //set to the view
     $this->set(compact('arrList'));

这是视图中的代码

echo $this->Form->select('NewLead', $arrList, array('multiple' => 'true', 'id' => 'NewLeadList'));

我做错了什么?

1 个答案:

答案 0 :(得分:1)

 // retrieve new lead list
     $arrList = $this->NewLead->find('list', array('fields'=>array("id","name_whatever"),'order' => 'newlead_name'));          

     //set to the view
     $this->set(compact('arrList'));
   //here is the code in view
   echo $this->Form->select('NewLead', array('multiple' => 'true', 'id' => 'NewLeadList','options'=>$arrList));