Reputation: 53
I have problem with virtual field, can you help me?
My model 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)');
My controller UserAddressesController:
$users = $this->User->find('list', array('list',array('fields' => array("id","users_list"))));
$this->set(compact('users'));
My view UserAddresses/edit:
<?php echo $this->Form->input('users_id', array('class' => 'form-control')); ?>
Report notice:
Notice (8): Undefined variable: users_list [APP/Plugin/User/Controller/UserAddressesController.php, line 94] Code Context
array('fields' => array("id","users_list"))));
Upvotes: 0
Views: 120
Reputation: 616
The resolution from the comment above:
The find call doesn't need the 'list'
value in the options array. It should just be $this->User->find('list', array('fields' => array(...
Upvotes: 0