Bonjour,

j'affronte un nouveau problème ces derniers jours, je n'arrive pas a mettre a jour le formulaire sur les informations de l'utilisateur connecté!
C'est a dire j'ai une erreur comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
The form's view data is expected to be an instance of class Symfony\Component\HttpFoundation\File\File, but is a(n) string. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms a(n) string to an instance of Symfony\Component\HttpFoundation\File\File.
Et dans Doctrine, j'ai ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
SELECT t0.id_adherent AS id_adherent1, t0.nom_adherent AS nom_adherent2, t0.prenom_adherent AS prenom_adherent3, t0.adresse_adherent AS adresse_adherent4, t0.tel_adherent AS tel_adherent5, t0.mail_adherent AS mail_adherent6, t0.cp_adherent AS cp_adherent7, t0.ville_adherent AS ville_adherent8, t0.anniv_adherent AS anniv_adherent9, t0.date_adherent AS date_adherent10, t0.pseudo_adherent AS pseudo_adherent11, t0.mot_de_passe_adherent AS mot_de_passe_adherent12, t0.photo_adherent AS photo_adherent13 FROM adherent t0 WHERE t0.pseudo_adherent = ? LIMIT 1
Parameters: [edd_83]
Time: 4.87 ms
Je vous ai mit en gras, ce que je pense être le problème!


Et voici mon defaul Controller avec la fonction modifier_profilAction():

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
<?php
 
namespace SymfonyCapsule\CapsuleBundle\Controller;
 
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use SymfonyCapsule\CapsuleBundle\Entity\Adherent;
use SymfonyCapsule\CapsuleBundle\Form\AdherentType;
use SymfonyCapsule\CapsuleBundle\Entity\Capsule;
use SymfonyCapsule\CapsuleBundle\Form\CapsuleType;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
 
class DefaultController extends Controller {
 
    public function indexAction() {
        //Acceuil
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:index.html.twig');
    }
 
    public function inscriptionAction() {
        $em = $this->getDoctrine()->getEntityManager();
 
        $a = new Adherent();
        $form = $this->createForm(new AdherentType(), $a);
 
        $request = $this->getRequest();
        if ($request->isMethod('POST')) {
            $form->bindRequest($request);
 
            if ($form->isValid()) {
                $a = $form->getData();
                $em->persist($a);
                $em->flush();
 
                return $this->redirect($this->generateUrl("symfony_capsule_capsule_homepage"));
            }
        }
 
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:inscription.html.twig', array(
                    'form' => $form->createView(),
                ));
    }
 
    public function voirAction() {
        //affichage de toutes les capsules
        $em = $this->getDoctrine()->getEntityManager();
        $capsule = $em->getRepository("SymfonyCapsuleCapsuleBundle:Capsule")->findAll();
 
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:voir.html.twig', array(
                    'capsules' => $capsule,
                ));
    }
 
    public function detailAction(Capsule $capsule) {
        //detail de la capsule selectionné
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:detail.html.twig', array(
                    'capsule' => $capsule,
                ));
    }
 
    public function modifier_profilAction() {
 
        $em = $this->getDoctrine()->getEntityManager();
        // récupération de l'utilisateur
        $adherent = $this->get('security.context')->getToken()->getUser();
        // création d'un objet formulaire suivant un modèle type et préchargé avec les données de notre utilisateur
        $editForm = $this->createForm(new AdherentType(), $adherent);
        // récupération des données du formulaire (entre autres)
        $request = $this->getRequest();
        //si la methode est un post alors
        if ($request->isMethod('POST')) {
            // hydratation de l'utilisateur avec TOUTES les données issues du formulaire
            $editForm->bindRequest($request);
            //si le formulaire est valide alors
            if ($editForm->isValid()) {
                //on persist l'envoi du formulaire et on flush vers la base de donnée
                $em->persist($adherent);
                $em->flush();
                //redirection vers l'index
                return $this->redirect($this->generateUrl("symfony_capsule_capsule_profil"));
            }
        }
    }
 
    public function ajouterAction() {
        //On recupère la classe EntityManager
        $em = $this->getDoctrine()->getEntityManager();
        //nouvel objet de capsule
        $a = new Capsule();
        //creation du formulaire CapsuleType
        $form = $this->createForm(new CapsuleType(), $a);
        //on recupère la fonction getRequest de la classe Controller
        $request = $this->getRequest();
        //si la methode est un post alors
        if ($request->isMethod('POST')) {
            $form->bindRequest($request);
            //si le formulaire est valide alors
            if ($form->isValid()) {
                $maison = $em->getRepository('SymfonyCapsuleCapsuleBundle:Maison')->find($a->getIdMaison());
                $a->setIdMaison($maison);
 
                /*
                 * affiche les valeurs des variables
                 * $a = $form->getData();
                 * var_dump($form->getData());
                 * exit;
                 */
 
                //on persist l'envoi du formulaire et on flush vers la base de donnée
                $em->persist($a);
                $em->flush();
                //redirection vers l'index
                return $this->redirect($this->generateUrl("symfony_capsule_capsule_index"));
            }
        }
 
 
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:ajouter.html.twig', array(
                    'form' => $form->createView(),
                ));
    }
 
    public function loginAction() {
        $request = $this->getRequest();
        $session = $request->getSession();
        // get the login error if there is one
        if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
            $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
        } else {
            $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
            $session->remove(SecurityContext::AUTHENTICATION_ERROR);
        }
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:login.html.twig', array(
                    // last username entered by the user
                    'last_username' => $session->get(SecurityContext::LAST_USERNAME),
                    'error' => $error,
                ));
    }
 
    public function profilAction() {
        $utilisateur = $this->get('security.context')->getToken()->getUser();
 
 
        return $this->render('SymfonyCapsuleCapsuleBundle:Default:profil.html.twig', array(
                    'utilisateur' => $utilisateur,
                ));
    }
 
}
Est-ce que quelqu'un aurait une idée?
Merci!