我有虚拟领域的问题,你能帮帮我吗?
我的模型UserAddress
public $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $virtualFields = array('users_list' => 'concat(User.name, " - ", User.surname, " - ", User.email)');
我的控制器UserAddressesController:
$users = $this->User->find('list', array('list',array('fields' => array("id","users_list"))));
$this->set(compact('users'));
我的观点UserAddresses / edit:
<?php echo $this->Form->input('users_id', array('class' => 'form-control')); ?>
报告通知:
注意(8):未定义的变量:users_list [APP / Plugin / User / Controller / UserAddressesController.php,第94行] 代码上下文
数组(&#39;字段&#39; =&gt;数组(&#34; id&#34;,&#34; users_list&#34;))));
答案 0 :(得分:0)
上述评论的决议:
find调用不需要options数组中的'list'
值。它应该是$this->User->find('list', array('fields' => array(...