Reputation: 9158
I have two tables A (Utenti) e B (Dispositivi); on B there is a foreign key to A (one Utente->many Dispositivi). I used symfony admin generator. Can I generate a link for each Utente that list me all the related Dispositivi in the Dispositivi view. Is it possible this?
schema.yml
Dispositivi:
connection: doctrine
tableName: dispositivi
columns:
id_dispositivo:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
device_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
utente_fk:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Utenti:
local: utente_fk
foreign: id_utente
type: one
Utenti:
connection: doctrine
tableName: utenti
columns:
id_utente:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
username:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
password:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Dispositivi:
local: id_utente
foreign: utente_fk
type: many
Servizi:
local: id_utente
foreign: utente_fk
type: many
Upvotes: 2
Views: 602
Reputation: 350
Here is a good reference for doctrine code:
http://redotheweb.com/2008/07/08/comparing-propel-doctrine-and-sfpropelfinder/ (especially if fou are used to propel.)
First, add a partial in the generator.yml file.
Then do something like this:
<?php
$dispositivis = $utente->Dispositivis;
?>
<?php foreach ($dispositivis as $d): ?>
<?php echo link_to($d->getTipo(), 'module_name/action_name?id='. $d->getIdDispositivo()) ?><br />
<?php endforeach ?>
Upvotes: 1