IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Erreur : Entities passed to the choice field must be managed [2.x]


Sujet :

Symfony PHP

  1. #1
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2008
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Somme (Picardie)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2008
    Messages : 20
    Points : 20
    Points
    20
    Par défaut Erreur : Entities passed to the choice field must be managed
    Bonjour à tous

    Je suis ici pour lancer un appel à l'aide car je suis bloqué depuis hier sur le même problème et malgré mes recherches, pas moyen de me débloquer

    Pour vous expliquer brièvement le contexte, j'ai deux entités "Lieu" et "Caracteristique".
    Chaque Lieu (ex.: Decathlon Paris rive gauche) peut avoir 0, 1 ou plusieurs Caracteristiques (ex.: magasin, sport).

    J'ai donc mes 2 entités dont voici le code :

    Lieu.php
    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
    <?php
     
    namespace XXX\MainBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
    use Doctrine\Common\Collections\ArrayCollection;
     
    /**
     * XXX\MainBundle\Entity\Lieu
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="XXX\MainBundle\Entity\LieuRepository")
     */
    class Lieu
    {
        /**
         * @var integer $id
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string $nom
         *
         * @ORM\Column(name="nom", type="string", length=120)
         */
        private $nom;
     
        /**
         * @var decimal $latitude
         *
         * @ORM\Column(name="latitude", type="decimal", precision="20", scale="17")
         */
        private $latitude;
     
        /**
         * @var decimal $longitude
         *
         * @ORM\Column(name="longitude", type="decimal", precision="20", scale="17")
         */
        private $longitude;
     
        /**
         * @var integer $loc_precision
         *
         * @ORM\Column(name="loc_precision", type="integer", nullable="true")
         */
        private $loc_precision;
     
        /**
         * @ORM\Column(name="caracteristiques", type="array", nullable="true")
         * @ORM\ManyToOne(targetEntity="XXX\MainBundle\Entity\Caracteristique", cascade={"persist"})
         */
        private $caracteristiques;
     
        /**
         * Constructeur
         */
        public function __construct() {
        	$this->caracteristiques = new ArrayCollection();
        }
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set nom
         *
         * @param string $nom
         */
        public function setNom($nom)
        {
            $this->nom = $nom;
        }
     
        /**
         * Get nom
         *
         * @return string 
         */
        public function getNom()
        {
            return $this->nom;
        }
     
        /**
         * Set latitude
         *
         * @param decimal $latitude
         */
        public function setLatitude($latitude)
        {
            $this->latitude = $latitude;
        }
     
        /**
         * Get latitude
         *
         * @return decimal 
         */
        public function getLatitude()
        {
            return $this->latitude;
        }
     
        /**
         * Set longitude
         *
         * @param decimal $longitude
         */
        public function setLongitude($longitude)
        {
            $this->longitude = $longitude;
        }
     
        /**
         * Get longitude
         *
         * @return decimal 
         */
        public function getLongitude()
        {
            return $this->longitude;
        }
     
        /**
         * Set loc_precision
         *
         * @param integer $locPrecision
         */
        public function setLocPrecision($locPrecision)
        {
            $this->loc_precision = $locPrecision;
        }
     
        /**
         * Get loc_precision
         *
         * @return integer 
         */
        public function getLocPrecision()
        {
            return $this->loc_precision;
        }
     
        /**
         * Add caracteristique
         * 
         * @param Caracteristique $caracteristique
         */
        public function addCaracteristique(Caracteristique $caracteristique) {
        	$this->caracteristiques[] = $caracteristique;
        }
     
        /**
         * Set caracteristiques
         */
        public function setCaracteristiques(ArrayCollection $caracteristiques) {
        	$this->caracteristiques = $caracteristiques;
        }
     
        /**
         * Get caracteristiques
         */
        public function getCaracteristiques() {
        	return $this->caracteristiques;
        }
    }
    Caracteristique.php
    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
    <?php
     
    namespace XXX\MainBundle\Entity;
     
    use Doctrine\Common\Collections\ArrayCollection;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * XXX\MainBundle\Entity\Caracteristique
     *
     * @ORM\Table()
     * @ORM\Entity(repositoryClass="XXX\MainBundle\Entity\CaracteristiqueRepository")
     */
    class Caracteristique
    {
        /**
         * @var integer $id
         *
         * @ORM\Column(name="id", type="integer")
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string $nom
         *
         * @ORM\Column(name="nom", type="string", length=100)
         */
        private $nom;
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set nom
         *
         * @param string $nom
         */
        public function setNom($nom)
        {
            $this->nom = $nom;
        }
     
        /**
         * Get nom
         *
         * @return string 
         */
        public function getNom()
        {
            return $this->nom;
        }
    }
    A partir de ça, j'ai voulu générer un CRUD (en utilisant la console) de mon entité Lieu.

    J'arrive à ajouter un nouveau Lieu (méthode create), afficher ses données (méthode read), l'effacer ( méthode delete), mais pas à l'éditer (méthode edit) !!!

    Voici l'erreur qui ressort lorsque je vais sur ma page http://localhost/XXX/web/app_dev.php/lieu/crud/3/edit :

    Entities passed to the choice field must be managed
    L'erreur est connue d'après ce que je vois sur les différents forums mais y'a rien à faire, je dois oublier quelque chose...

    Voici les codes de mes 2 controllers, ainsi que mon formulaire pour le Lieu.

    LieuController.php
    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
    180
    181
    182
    183
    184
    185
    186
    187
    <?php
     
    namespace XXX\MainBundle\Controller;
     
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
     
    use XXX\MainBundle\Entity\Lieu;
    use XXX\MainBundle\Form\LieuType;
     
    /**
     * Lieu controller.
     *
     */
    class LieuController extends Controller
    {
        /**
         * Lists all Lieu entities.
         *
         */
        public function indexAction()
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entities = $em->getRepository('XXXMainBundle:Lieu')->findAll();
     
            return $this->render('XXXMainBundle:Lieu:index.html.twig', array(
                'entities' => $entities
            ));
        }
     
        /**
         * Finds and displays a Lieu entity.
         *
         */
        public function showAction($id)
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entity = $em->getRepository('XXXMainBundle:Lieu')->find($id);
     
            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Lieu entity.');
            }
     
            $deleteForm = $this->createDeleteForm($id);
     
            return $this->render('XXXMainBundle:Lieu:show.html.twig', array(
                'entity'      => $entity,
                'delete_form' => $deleteForm->createView(),
     
            ));
        }
     
        /**
         * Displays a form to create a new Lieu entity.
         *
         */
        public function newAction()
        {
            $entity = new Lieu();
            $form   = $this->createForm(new LieuType(), $entity);
     
            return $this->render('XXXMainBundle:Lieu:new.html.twig', array(
                'entity' => $entity,
                'form'   => $form->createView()
            ));
        }
     
        /**
         * Creates a new Lieu entity.
         *
         */
        public function createAction()
        {
            $entity  = new Lieu();
            $request = $this->getRequest();
            $form    = $this->createForm(new LieuType(), $entity);
            $form->bindRequest($request);
     
            if ($form->isValid()) {
                $em = $this->getDoctrine()->getEntityManager();
                $em->persist($entity);
                $em->flush();
     
                return $this->redirect($this->generateUrl('lieu_show', array('id' => $entity->getId())));
     
            }
     
            return $this->render('XXXMainBundle:Lieu:new.html.twig', array(
                'entity' => $entity,
                'form'   => $form->createView()
            ));
        }
     
        /**
         * Displays a form to edit an existing Lieu entity.
         *
         */
        public function editAction($id)
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entity = $em->getRepository('XXXMainBundle:Lieu')->find($id);
     
            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Lieu entity.');
            }
     
            $editForm = $this->createForm(new LieuType(), $entity);
            $deleteForm = $this->createDeleteForm($id);
     
            return $this->render('XXXMainBundle:Lieu:edit.html.twig', array(
                'entity'      => $entity,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
     
        /**
         * Edits an existing Lieu entity.
         *
         */
        public function updateAction($id)
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entity = $em->getRepository('XXXMainBundle:Lieu')->find($id);
     
            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Lieu entity.');
            }
     
            $editForm   = $this->createForm(new LieuType(), $entity);
            $deleteForm = $this->createDeleteForm($id);
     
            $request = $this->getRequest();
     
            $editForm->bindRequest($request);
     
            if ($editForm->isValid()) {
                $em->persist($entity);
                $em->flush();
     
                return $this->redirect($this->generateUrl('lieu_edit', array('id' => $id)));
            }
     
            return $this->render('XXXMainBundle:Lieu:edit.html.twig', array(
                'entity'      => $entity,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
     
        /**
         * Deletes a Lieu entity.
         *
         */
        public function deleteAction($id)
        {
            $form = $this->createDeleteForm($id);
            $request = $this->getRequest();
     
            $form->bindRequest($request);
     
            if ($form->isValid()) {
                $em = $this->getDoctrine()->getEntityManager();
                $entity = $em->getRepository('XXXMainBundle:Lieu')->find($id);
     
                if (!$entity) {
                    throw $this->createNotFoundException('Unable to find Lieu entity.');
                }
     
                $em->remove($entity);
                $em->flush();
            }
     
            return $this->redirect($this->generateUrl('lieu'));
        }
     
        private function createDeleteForm($id)
        {
            return $this->createFormBuilder(array('id' => $id))
                ->add('id', 'hidden')
                ->getForm()
            ;
        }
    }
    CaracteristiqueController.php
    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
    180
    181
    182
    183
    184
    185
    186
    187
    <?php
     
    namespace XXX\MainBundle\Controller;
     
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
     
    use XXX\MainBundle\Entity\Caracteristique;
    use XXX\MainBundle\Form\CaracteristiqueType;
     
    /**
     * Caracteristique controller.
     *
     */
    class CaracteristiqueController extends Controller
    {
        /**
         * Lists all Caracteristique entities.
         *
         */
        public function indexAction()
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entities = $em->getRepository('XXXMainBundle:Caracteristique')->findAll();
     
            return $this->render('XXXMainBundle:Caracteristique:index.html.twig', array(
                'entities' => $entities
            ));
        }
     
        /**
         * Finds and displays a Caracteristique entity.
         *
         */
        public function showAction($id)
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entity = $em->getRepository('XXXMainBundle:Caracteristique')->find($id);
     
            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Caracteristique entity.');
            }
     
            $deleteForm = $this->createDeleteForm($id);
     
            return $this->render('XXXMainBundle:Caracteristique:show.html.twig', array(
                'entity'      => $entity,
                'delete_form' => $deleteForm->createView(),
     
            ));
        }
     
        /**
         * Displays a form to create a new Caracteristique entity.
         *
         */
        public function newAction()
        {
            $entity = new Caracteristique();
            $form   = $this->createForm(new CaracteristiqueType(), $entity);
     
            return $this->render('XXXMainBundle:Caracteristique:new.html.twig', array(
                'entity' => $entity,
                'form'   => $form->createView()
            ));
        }
     
        /**
         * Creates a new Caracteristique entity.
         *
         */
        public function createAction()
        {
            $entity  = new Caracteristique();
            $request = $this->getRequest();
            $form    = $this->createForm(new CaracteristiqueType(), $entity);
            $form->bindRequest($request);
     
            if ($form->isValid()) {
                $em = $this->getDoctrine()->getEntityManager();
                $em->persist($entity);
                $em->flush();
     
                return $this->redirect($this->generateUrl('caracteristique_show', array('id' => $entity->getId())));
     
            }
     
            return $this->render('XXXMainBundle:Caracteristique:new.html.twig', array(
                'entity' => $entity,
                'form'   => $form->createView()
            ));
        }
     
        /**
         * Displays a form to edit an existing Caracteristique entity.
         *
         */
        public function editAction($id)
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entity = $em->getRepository('XXXMainBundle:Caracteristique')->find($id);
     
            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Caracteristique entity.');
            }
     
            $editForm = $this->createForm(new CaracteristiqueType(), $entity);
            $deleteForm = $this->createDeleteForm($id);
     
            return $this->render('XXXMainBundle:Caracteristique:edit.html.twig', array(
                'entity'      => $entity,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
     
        /**
         * Edits an existing Caracteristique entity.
         *
         */
        public function updateAction($id)
        {
            $em = $this->getDoctrine()->getEntityManager();
     
            $entity = $em->getRepository('XXXMainBundle:Caracteristique')->find($id);
     
            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Caracteristique entity.');
            }
     
            $editForm   = $this->createForm(new CaracteristiqueType(), $entity);
            $deleteForm = $this->createDeleteForm($id);
     
            $request = $this->getRequest();
     
            $editForm->bindRequest($request);
     
            if ($editForm->isValid()) {
                $em->persist($entity);
                $em->flush();
     
                return $this->redirect($this->generateUrl('caracteristique_edit', array('id' => $id)));
            }
     
            return $this->render('XXXMainBundle:Caracteristique:edit.html.twig', array(
                'entity'      => $entity,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
     
        /**
         * Deletes a Caracteristique entity.
         *
         */
        public function deleteAction($id)
        {
            $form = $this->createDeleteForm($id);
            $request = $this->getRequest();
     
            $form->bindRequest($request);
     
            if ($form->isValid()) {
                $em = $this->getDoctrine()->getEntityManager();
                $entity = $em->getRepository('XXXMainBundle:Caracteristique')->find($id);
     
                if (!$entity) {
                    throw $this->createNotFoundException('Unable to find Caracteristique entity.');
                }
     
                $em->remove($entity);
                $em->flush();
            }
     
            return $this->redirect($this->generateUrl('caracteristique'));
        }
     
        private function createDeleteForm($id)
        {
            return $this->createFormBuilder(array('id' => $id))
                ->add('id', 'hidden')
                ->getForm()
            ;
        }
    }
    LieuType.php
    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
    <?php
     
    namespace XXX\MainBundle\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
    use XXX\MainBundle\Entity\CaracteristiqueRepository;
     
    class LieuType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options)
        {
            $builder
                ->add('nom')
                ->add('latitude')
                ->add('longitude')
                ->add('loc_precision')
    			->add('caracteristiques', 'entity', array(
    					'class'			=> 'XXX\MainBundle\Entity\Caracteristique', 
          				'property'		=> 'nom',
          				'multiple'		=> true,
    					'required'		=> false));
        }
     
        public function getName()
        {
            return 'XXX_mainbundle_lieutype';
        }
    }
    Je commence à désespérer...
    Si quelqu'un pouvait m'aider, je lui en serai extrêmenent reconnaissant

  2. #2
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Juin 2011
    Messages
    725
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juin 2011
    Messages : 725
    Points : 1 050
    Points
    1 050
    Par défaut
    Bonjour,

    Il y a un problème dans ton mapping
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    //#Entity\Lieu.php
    /**
    * @ORM\Column(name="caracteristiques", type="array", nullable="true")
    * @ORM\ManyToOne(targetEntity="XXX\MainBundle\Entity\Caracteristique", cascade={"persist"})
    */
    private $caracteristiques;
    Ton attribut caractéristiques est mappé à la fois comme column et comme relation. Doctrine semble donc s'arréter à la première déclaration.

    D'autre part si tu le déclare en ManyToOne cela veut dire qu'une entité Lieu est en relation avec une seule entité Caractéristique ce qui ne correspond pas à ce que tu veux.

    Si une caractéristique est lié à une seule entité Lieu, le mapping sera :
    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
    //#Entity\Lieu.php
    /**
    * @ORM\OneToMany(targetEntity="XXX\MainBundle\Entity\Caracteristique",mappedBy="lieu", cascade={"persist")
    **/
    private $caracteristiques;
     
    public function __construct(){
    $this->caracteristiques=new \Doctrine\Common\Collection\ArrayCollection();
    }
     
    //#Entity\Caracteristique.php
    /**
    * @ORM\ManyToOne(targetEntity="XXX\MainBundle\Entity\Lieu",inversedBy="caracteristiques")
    **/
    private $lieu
    Si une caractéristique peut être lié à plusieurs lieu, ton mapping sera un ManyToMany

  3. #3
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2008
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Somme (Picardie)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2008
    Messages : 20
    Points : 20
    Points
    20
    Par défaut
    Bonsoir Arno !

    Tout d'abord, merci beaucoup d'accorder du temps à mon problème

    Tu viens de relever un point qui m'a échappé dans ta dernière phrase... j'ai mal étudié la relation que j'allais devoir utiliser
    Une Caracteristique peut être liée à plusieurs Lieux et un Lieu peut comporter plusieurs Caracteristiques, il me faut donc bien utiliser un ManyToMany !!!

    Est-ce correct écrit comme ça?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    //#Entity\Lieu.php
    /**
    * @ORM\ManyToMany(targetEntity="XXX\MainBundle\Entity\Caracteristique", cascade={"persist")
    **/
    private $caracteristiques;
    Encore merci.

  4. #4
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2008
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Somme (Picardie)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2008
    Messages : 20
    Points : 20
    Points
    20
    Par défaut
    Je viens de mettre à jour mon code comme et ça marche à merveille

    Encore merci Arno

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [EJB3] Erreur "detached entity passed to persist"
    Par ADBows dans le forum Java EE
    Réponses: 1
    Dernier message: 14/08/2013, 14h07
  2. [2.x] Entities passed to the choice field must have a "__toString()"
    Par pingolitipus dans le forum Symfony
    Réponses: 12
    Dernier message: 17/05/2012, 12h34
  3. [2.x] Pré-sélectionné une valeur dans un entity choice field
    Par Invité dans le forum Symfony
    Réponses: 1
    Dernier message: 31/07/2011, 22h56
  4. Erreur "static reference to the non-static field"
    Par NetLandGim dans le forum AWT/Swing
    Réponses: 4
    Dernier message: 04/04/2011, 00h55
  5. Réponses: 1
    Dernier message: 26/07/2007, 17h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo