Bonjour,
J'ai un petit problèmes avec synfony et l'admin generator.
J’essaie de faire une liaison Many to Many mais je ne comprend pas exactement l'erreur obtenu.
J'ai une table recyclage, une table département et une table recyclage_departement. Le but est de pouvoir lié plusieurs département à chaque recyclage dans l'admin generator.
J'ai créé les clé étrangères :
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 ALTER TABLE `recyclage_departement` ADD CONSTRAINT `fk_departement` FOREIGN KEY (`idDepartement`) REFERENCES `departement` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, ADD CONSTRAINT `fk_recyclage` FOREIGN KEY (`idRecyclage`) REFERENCES `recyclage` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
Et modifier mon fichier generator.yml :
Pour infos voici mon fichier schema :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 display: [nom, siteweb, idrecyclage] fields: idrecyclage: { type: admin_check_list, params: through_class=RecyclageDepartement }
Lors de l’édition j'ai l'erreur "Widget "idrecyclage" does not exist."
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 Departement: connection: doctrine tableName: departement columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true nom: type: string(255) fixed: false unsigned: false primary: false notnull: false autoincrement: false numero: type: string(1) fixed: false unsigned: false primary: false notnull: false autoincrement: false article: type: string(45) fixed: false unsigned: false primary: false notnull: true autoincrement: false relations: RecyclageDepartement: local: id foreign: iddepartement type: many Recyclage: connection: doctrine tableName: recyclage columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true nom: type: string(255) fixed: false unsigned: false primary: false notnull: false autoincrement: false siteweb: type: string(255) fixed: false unsigned: false primary: false notnull: false autoincrement: false relations: RecyclageDepartement: local: id foreign: idrecyclage type: many RecyclageDepartement: connection: doctrine tableName: recyclage_departement columns: id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true iddepartement: type: integer(4) fixed: false unsigned: false primary: false notnull: false autoincrement: false idrecyclage: type: integer(4) fixed: false unsigned: false primary: false notnull: false autoincrement: false relations: Recyclage: local: idrecyclage foreign: id type: one Departement: local: iddepartement foreign: id type: one
Quelqu'un sait comment je dois nommer le champ ou me guider, le tutoriel officiel n'est pas très étoffé par les relations Many to Many.
Merci de votre aide.
Partager