endo.anaconda
endo.anaconda

Reputation: 2468

virtual fields in associated view

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.

Upvotes: 0

Views: 115

Answers (1)

mark
mark

Reputation: 21743

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'];

Upvotes: 1

Related Questions