Saturday, July 30, 2011

$virtualField combining fields from two models?

Hi,

I have one Agent model and one EstateAgency model like this...
(cakePHP 1.3.11)

class Agent extends AppModel {
var $belongsTo = 'EstateAgency';
}

class EstateAgency extends AppModel {
var $hasMany = 'Agent';
}

Now I'm trying to create a virtual field, that combines the name of
the agent and the agency, in the Agent class.

Here is my attempt that I can't get to work:
class Agent extends AppModel {
var $belongsTo = 'EstateAgency';
var $virtualFields = array(
'virtualTest' => "CONCAT(Agent.name, ' - ',
EstateAgency.name)"
);
}

What am I doing wrong? Or is this even possible to do this way?

thanks
/Ludde

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: