0

I'm having $virtualFields of users set in the model

public $virtualFields = array(
    'fullname' => 'CONCAT(user.firstname, " ", user.lastname)',
    [...]
);

I want to access this field in a associated view, but I can load users data like firstname in the other view, but not the combined field fullname.

Do I have to add something into the controller to get this field.

tereško
  • 58,060
  • 25
  • 98
  • 150
endo.anaconda
  • 2,449
  • 4
  • 29
  • 55

1 Answers1

1

You probably didnt read the last chapter of the book page here: http://book.cakephp.org/2.0/en/models/virtual-fields.html#limitations-of-virtualfields

Otherwise you would have seen, how do overcome the limitation of virtual fields here:

$this->virtualFields['fullname'] = $this->User->virtualFields['fullname'];
mark
  • 21,691
  • 3
  • 49
  • 71