我的控制员。
$times=$this->Time->find('list',array('fields'=>$this->Time->virtualFields['name_price'] ));
$this->set('time',compact($times));
我在我的模型Time
中添加了以下行public $virtualFields = array('name_price' => 'concat(Time.varaddress1, "-", Time.varaddress2)');
我的ctp文件在
之下<?echo $this->Form->input('intaddressid', array(
'options' => $time,'label'=>false,'empty' => '(Select Information)'
,'class' => 'form-control border_none'
));?>
但现在在输出中我没有选择任何文件。!!
当我回复$ time时,我得到了'Array()
我希望在选择字段
<option>varaddress1,varaddress2</option>
答案 0 :(得分:2)
您需要更改控制器代码,如:
$times=$this->Time->find('list',array('fields'=>array('Time.id','Time.name_price')));
$this->set(compact('times'));