Bonjours,
j'éprouve des difficultés pour faire des jointures dans mon panel admin(avec admin generator).
J'utilise Symfony 1.2.9 & doctrine.
On va commencé par mon model de donnée schema.yml
Code schema.yml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 SubDomain: columns: id: name: relations: SubDomainFrom: foreignType: many alias: SubDomainFrom local: id foreign: sub_domain_from class: Redirect SubDomainTo: foreignType: many alias: SubDomainTo local: id foreign: sub_domain_to class: Redirect Redirect: columns: id: sub_domain_from: sub_domain_to:
Globalement c'est ca, j'ai enlevé le superflus.
j'ai utilisé une table method pour limité le nombre de requête mais théoriquement ca change rien au problème en cas :
Code generator.yml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 list: layout: stacked display: [id, sub_domain_from] params: %%id%% - %%SubDomainFrom%% table_method: retriveRedirectList
Code RedirectTable.class.php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 public function retriveRedirectList(Doctrine_Query $q) { $rootAlias = $q->getRootAlias(); $q->leftJoin($rootAlias . '.SubDomain s'); return $q; }
Bon voila mon besoin et de remplacer le l'id que renvoie %%SubDomain%% par son nom.
sur le tuto Joobeet ils explique :
Je vous passe les blogs que j'ai pue lire."Virtual" columns
With this configuration, the %%category_id%% segment will be replaced by the category primary key. But it would be more meaningful to display the name of the category.
Whenever you use the %% notation, the variable does not need to correspond to an actual column in the database schema. The admin generator only need to find a related getter in the model class.
To display the category name, we can define a getCategoryName() method in the JobeetJob model class and replace %%category_id%% by %%category_name%%.
But the JobeetJob class already has a getJobeetCategory() method that returns the related category object. And if you use %%jobeet_category%%, it works as the JobeetCategory class has a magic __toString() method that converts the object to a string.
Je dois manqué de recule sur la techno le problème me semble un peu trivial quand même mais je n'arrive pas à le résoudre :/
Y'a t'il une âme charitable pour m'expliquer les choses?
Partager