tl;dr: I need to show data from two different tables in the list view of the Symfony admin generator (preferably via a JOIN statement)
I'm using the sfDoctrineGuardPlugin
to manage the users of my app. Each user also has their own profile that they can fill out. The schema (schema.yml
) for the profile table looks like this:
sfGuardUserProfile:
connection: doctrine
tableName: sf_guard_user_profile
columns:
sf_guard_user_id: integer(8)
client_id: string(128)
relations:
sfGuardUser:
local: sf_guard_user_id
foreign: id
foreignType: one
onDelete: CASCADE
Right now table is a client_id and a foreign key to the id column on the sfGuardUser table. (Yes, I know I need an id column in there just for DB accessibility, and more is coming later)
I've created an admin for my profile table using the Symfony admin generator. I would like my list view on the admin to look like this (generator.yml
):
config:
...
list:
title: Clients
display: [client_id, sf_guard_user_id, username]
table_method: retrieveProfileList
However, my username column does not work, and I receive a Doctrine_Record_UnkownPropertyException
of:
Unknown record property / related component "username" on "sfGuardUserProfile"
I was hoping a custom table_method to populate the data for the list view would help me, but my table method (in lib/model/sfGuardUserProfileTable.class.php
) does not seem to help. I followed an example in the Symfony Book, and this is the method:
public static function retrieveProfileList(Doctrine_Query $q)
{
$rootAlias = $q->getRootAlias();
$q->leftJoin($rootAlias . '.sfGuardUser id');
return $q;
}
Any ideas on how to have the Symfony admin generator display a list view based on a join? Or, alternatively, how to pull from a separate model?