Bonjour
Je cherche a filter un collection :
j'ai un entity accred qui a une collection de participant.
et je veux que quand j'édit le participant et qui a la value =>accreditvalide: false ne s'affiche pas.
voir un dump du form:
j'ai de traité sa par addEventListener mais sens scucess:
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 Accred {#764 ▼ #id: 60 #numeroDossier: "JL_sss" #dateStatut: DateTime {#767 ▶} #statut: "brouillon" #lastStep: 2 #montantHt: 65.0 #participants: PersistentCollection {#615 ▼ -snapshot: array:2 [ 2] -owner: Accreditation {#764} -association: array:15 [ 15] -em: EntityManager {#278 11} -backRefFieldName: "accreditation" -typeClass: ClassMetadata {#762 } -isDirty: false #collection: ArrayCollection {#753 ▼ -elements: array:2 [▼ 0 => Participants {#888 ▼ -id: 20 -nom: "lefebvre" -prenom: "nicolas" -fonction: "sasa" -codebar: false -codevalue: null -email: "nlefebvre@gmx.fr" -language: "fr" -country: "FR" -choix: "155" -choixprix: 155 -hebergement: true #accreditation: Accreditation {#764} #hotel: Hotel {#920 ▶} #prices_bedbedroom: "2820" #date_hotel: array:1 [▶] #accreditvalide: false -status: "brouillon" -devise: false -vip: true } 1 => Participants {#919 ▶} ] } #initialized: true }
merci de votre aide
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 $builder ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $user = $event->getData(); $form = $event->getForm(); $config = $form->getConfig(); foreach ($user->getParticipants() as $participant){ if($participant->getAccreditvalide()== false){ unset($user); }else{ } } $event->setData($user); }) ->getForm(); }
Partager