I have a little problem with the displayField
in combination with virtualFields
.
I have a File that belongsTo 2 different Users.
public $belongsTo = array(
'Creator' => array(
'className' => 'User',
'foreignKey' => 'creator_id',
),
'Editor' => array(
'className' => 'User',
'foreignKey' => 'editor_id',
)
);
As virtualField
and displayField
in the User Model. I use the following code:
public $virtualFields = array(
'full_name' => "CONCAT(first_name, ' ',last_name)"
);
public $displayField = 'full_name';
Creating a new File works fine, but if I want to view all my files I get the following error:
Error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'first_name' in field list is ambiguous
I already read about it a little here: http://book.cakephp.org/2.0/en/models/virtual-fields.html At the end there are some limitations about virtualFields, so I tried to add this to the Controller:
$this->virtualFields += $this->Creator->virtualFields;
$this->virtualFields += $this->Editor->virtualFields;
But somehow this doesn't change anything.
Hope you can help me with this little problem.
Thanks in advance!