Bonjour à tous.
Je viens vous voir afin de régler un petit (j'espère qu'il est petit ><) problème.
Ce que j'ai fais :
J'utilise à l'heure actuelle le plugin ahDoctrineEasyEmbeddedRelationsPlugin.
J'ai imbriqué un formulaire dans un autre et ce sans soucis.
Seulement voilà, maintenant, je dois imbriqué un formulaire au sein de celui que j'avais déja imbriqué.
Concrètement j'ai trois tables : CommandClient qui inclu le formulaire de la table CommandeMenu et une table relation ProduitsEnCommandeViaMenu qui fait la jointure entre ProduitEnVente, CommandeMenu et EtatProduitEnVente.
La où cela se gate c'est quand je veux remplir la relation ProduitEnCommandeViaMenu. J'ai donc utilisé le embedRelations() afin de pouvoir, au sein de ma CommandeMenu, insérer les produits commandés.
Seulement, étant une table relation, il est impossible d'accéder au champs de cette table qui sont en fait tous des clé primaires. Quand je dis "accéder" c'est faire apparaître des listes déroulante me permettant de choisir le produit à ajouter au sein de mon menu et son état (que je règlerais à une valeur par défaut plus tard).
Voici mon schema.yml (un peu long donc je vous passe ce qui est en rapport avec mon problème):
Mon CommandeClientForm.class.php imbriquant le formulaire de choix de menu pour CommandeMenu :
Code : 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179 Produitencommandeviamenu: connection: doctrine tableName: produitencommandeviamenu columns: idproduit: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false idcommandeclient: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false idcommandemenu: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false idetatproduitenvente: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false relations: Commandemenu: onDelete : CASCADE local: idcommandeclient foreign: idcommandeclient type: one Commandemenu_2: onDelete : CASCADE class: Commandemenu local: idcommandemenu foreign: idcommandemenu type: one Etatproduitenvente: onDelete : CASCADE local: idetatproduitenvente foreign: idetatproduitenvente type: one Produitenvente: onDelete : CASCADE local: idproduit foreign: idproduit type: one Etatproduitenvente: connection: doctrine tableName: etatproduitenvente columns: idetatproduitenvente: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true libelleetatproduitenvente: type: string(32) fixed: true unsigned: false primary: false notnull: false autoincrement: false relations: Produitencommandealacarte: onDelete : CASCADE local: idetatproduitenvente foreign: idetatproduitenvente type: many Produitencommandeviamenu: onDelete : CASCADE local: idetatproduitenvente foreign: idetatproduitenvente type: many Commandemenu: connection: doctrine tableName: commandemenu columns: idcommandeclient: type: integer(4) fixed: false unsigned: false primary: false notnull: true autoincrement: false idcommandemenu: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true idmenu: type: integer(8) fixed: false unsigned: false primary: false notnull: true autoincrement: false relations: Commandeclient: onDelete : CASCADE local: idcommandeclient foreign: idcommandeclient type: one Menu: onDelete : CASCADE local: idmenu foreign: idmenu type: one Produitencommandeviamenu: onDelete : CASCADE local: idcommandeclient foreign: idcommandeclient type: many Produitencommandeviamenu_2: onDelete : CASCADE class: Produitencommandeviamenu local: idcommandemenu foreign: idcommandemenu type: many Produitenvente: connection: doctrine tableName: produitenvente columns: idproduit: type: integer(4) fixed: false unsigned: false primary: true autoincrement: false idcategorie: type: integer(4) fixed: false unsigned: false primary: false notnull: true autoincrement: false prixunitaireproduitenvente: type: 'decimal(13, 2)' fixed: false unsigned: false primary: false notnull: false autoincrement: false libelleproduit: type: string(64) fixed: true unsigned: false primary: false notnull: false autoincrement: false relations: Categorie: onDelete : CASCADE local: idcategorie foreign: idcategorie type: one Produitauchoixdansmenu: onDelete : CASCADE local: idproduit foreign: idproduit type: many Produitencommandealacarte: onDelete : CASCADE local: idproduit foreign: idproduit type: many Produitencommandeviamenu: onDelete : CASCADE local: idproduit foreign: idproduit type: many
Voila. Dans Produitencommandeviamenu, j'ai tenté des trucs du genre
Code : 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 public function configure() { /**unset( $this['idserveur'],$this['idetatcommande'], $this['datecommandeclient'] );*/ $this->embedRelations(array( 'Commandemenu' => array( 'considerNewFormEmptyFields' => array(), 'multipleNewForms' => true, 'newFormsInitialCount' => 1, 'newRelationButtonLabel' => 'Ajouter un menu', 'formClassArgs' => array(array('ah_add_delete_checkbox' => true)) ) )); }
J'ai essayer de rendre visible les champs "hidden" définis dans la classe de base mais sans succès. Ca va faire 3 jours que je suis la dessus, donc je viens vous embêter un peu ^^
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 $this->widgetSchema['idproduit'] = new sfWidgetFormChoice(array( 'choices' => Doctrine_Core::getTable('Produitenvente')->findAll(), )); $this->widgetSchema['idetatproduitenvente'] = new sfWidgetFormChoice(array( 'choices' => Doctrine_Core::getTable('Etatproduitenvente')->findAll(), ));
Merci d'avance pour les coups de pouces ^^
Partager