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 en symfony2 [2.x]


Sujet :

Symfony PHP

  1. #1
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut erreur en symfony2
    Bonjour ,
    svp qui connait quelle est cette erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Entité "MyApp \ emploiBundle \ Entity \ PvJobLstServiceMilitaire" passé sur le terrain doit avoir un choix "__toString ()" méthode définie (ou vous pouvez également remplacer la «propriété» en option).
    et merci

  2. #2
    Membre éclairé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2012
    Messages
    394
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 394
    Par défaut
    Oui faut modifier certaines choses. donne nous le code du formulaire ...Type.php : faut définir les property !!

  3. #3
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    voila
    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
    <?php
     
    namespace MyApp\emploiBundle\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
     
    class PvJobCandInformationsGeneralesType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options)
        {
            $builder
                ->add('permisCand')
                ->add('voitureCand')
                ->add('servMilCand')
                ->add('idServiceMilitaire')
            ;
        }
     
        public function getName()
        {
            return 'myapp_emploibundle_pvjobcandinformationsgeneralestype';
        }
    }

  4. #4
    Membre éclairé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2012
    Messages
    394
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 394
    Par défaut
    Voila tu modifie seulement la ligne 16 au niveau de:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ->add('idServiceMilitaire')
    Enfait ce champ 'idServiceMilitaire' a une clé étrangère d'un id de la table PvJobLstServiceMilitaire.

    La solution c'est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    ->add('idServiceMilitaire', 'entity', array(
                        'class' => 'MyAppemploiBundle:PvJobLstServiceMilitaire',
                        'property' => 'id',
                        'label'=> 'Service Militaire:'))
    Moi j'ai définis 'id' comme property tu peux définir d'autres !!

  5. #5
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    merci pour votre repense
    et cette erreurs svp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'
    j 'ai fait un table lst de service militaire et elle un cobobox dans la formulaire candidat

  6. #6
    Membre éclairé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2012
    Messages
    394
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 394
    Par défaut
    J'ai eu ce genre d'erreurs ! tu essaies d'insérer une valeur de l''id' qui existe déjà n'oublies pas la valeur 'id' est unique pour ta procédure je n'ai pas bien compris, sois claire ! et on se tutoie

  7. #7
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    je sais pas pourquoi je peux pas envoyer des images pour vous expliquer

  8. #8
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    j 'ai dans la base deux tables

    le premier pv__job_cand_informations_generales
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
     
    Nom	Code	Type de données	Longueur	Précision	Primaire	Clé étrangère	Obligatoire
    id_infogénerale	id_infogenerale	int			TRUE	FALSE	TRUE
    id_service_militaire	id_service_militaire	int			FALSE	TRUE	TRUE
    permis_cand	permis_cand	varchar(254)	254		FALSE	FALSE	FALSE
    voiture_cand	voiture_cand	varchar(254)	254		FALSE	FALSE	FALSE
    serv_mil_cand	serv_mil_cand	varchar(254)	254		FALSE	FALSE	FALSE
    le deuxième est pv__job_lst_service_militaire:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Nom	Code	Type de données	Longueur	Précision	Primaire	Clé étrangère	Obligatoire
    id_service_militaire	id_service_militaire	int			TRUE	FALSE	TRUE
    serv_mil_cand	serv_mil_cand	varchar(254)	254		FALSE	FALSE	FALSE
    j'ai fait tout les commande jusqu 'a crud je veux faire une formulaire qui contient un cobobox qui est la liste de service militaire mais lorsque je fait l 'ajout dans la table lst j 'ai ajouter un valeur seulement puis il m 'affiche un erreur

  9. #9
    Membre éprouvé Avatar de Avrel
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2010
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Avril 2010
    Messages : 118
    Par défaut
    Montres nous ton entité stp

  10. #10
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    PvJobCandInformationsGenerales
    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
    <?php
     
    namespace MyApp\emploiBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * MyApp\emploiBundle\Entity\PvJobCandInformationsGenerales
     *
     * @ORM\Table(name="pv__job_cand_informations_generales")
     * @ORM\Entity
     */
    class PvJobCandInformationsGenerales
    {
        /**
         * @var integer $id
         *
         * @ORM\Column(name="id_infogenerale", type="integer", nullable=false)
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="IDENTITY")
         */
        private $id;
     
        /**
         * @var string $permisCand
         *
         * @ORM\Column(name="permis_cand", type="string", length=254, nullable=true)
         */
        private $permisCand;
     
        /**
         * @var string $voitureCand
         *
         * @ORM\Column(name="voiture_cand", type="string", length=254, nullable=true)
         */
        private $voitureCand;
     
        /**
         * @var string $servMilCand
         *
         * @ORM\Column(name="serv_mil_cand", type="string", length=254, nullable=true)
         */
        private $servMilCand;
     
        /**
         * @var PvJobLstServiceMilitaire
         *
         * @ORM\ManyToOne(targetEntity="PvJobLstServiceMilitaire")
         * @ORM\JoinColumns({
         *   @ORM\JoinColumn(name="id_service_militaire", referencedColumnName="id_service_militaire")
         * })
         */
        private $idServiceMilitaire;
     
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set permisCand
         *
         * @param string $permisCand
         */
        public function setPermisCand($permisCand)
        {
            $this->permisCand = $permisCand;
        }
     
        /**
         * Get permisCand
         *
         * @return string 
         */
        public function getPermisCand()
        {
            return $this->permisCand;
        }
     
        /**
         * Set voitureCand
         *
         * @param string $voitureCand
         */
        public function setVoitureCand($voitureCand)
        {
            $this->voitureCand = $voitureCand;
        }
     
        /**
         * Get voitureCand
         *
         * @return string 
         */
        public function getVoitureCand()
        {
            return $this->voitureCand;
        }
     
        /**
         * Set servMilCand
         *
         * @param string $servMilCand
         */
        public function setServMilCand($servMilCand)
        {
            $this->servMilCand = $servMilCand;
        }
     
        /**
         * Get servMilCand
         *
         * @return string 
         */
        public function getServMilCand()
        {
            return $this->servMilCand;
        }
     
        /**
         * Set idServiceMilitaire
         *
         * @param MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire $idServiceMilitaire
         */
        public function setIdServiceMilitaire(\MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire $idServiceMilitaire)
        {
            $this->idServiceMilitaire = $idServiceMilitaire;
        }
     
        /**
         * Get idServiceMilitaire
         *
         * @return MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire 
         */
        public function getIdServiceMilitaire()
        {
            return $this->idServiceMilitaire;
        }
    }
    PvJobLstServiceMilitaire
    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
    <?php
     
    namespace MyApp\emploiBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire
     *
     * @ORM\Table(name="pv__job_lst_service_militaire")
     * @ORM\Entity
     */
    class PvJobLstServiceMilitaire
    {
        /**
         * @var integer $id
         *
         * @ORM\Column(name="id_service_militaire", type="integer", nullable=false)
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="IDENTITY")
         */
        private $id;
     
        /**
         * @var integer $codeServiceMilitaire
         *
         * @ORM\Column(name="code_service_militaire", type="integer", nullable=true)
         */
        private $codeServiceMilitaire;
     
        /**
         * @var string $libServiceMilitaire
         *
         * @ORM\Column(name="lib_service_militaire", type="string", length=254, nullable=true)
         */
        private $libServiceMilitaire;
     
     
     
        /**
         * Get idServiceMilitaire
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set codeServiceMilitaire
         *
         * @param integer $codeServiceMilitaire
         */
        public function setCodeServiceMilitaire($codeServiceMilitaire)
        {
            $this->codeServiceMilitaire = $codeServiceMilitaire;
        }
     
        /**
         * Get codeServiceMilitaire
         *
         * @return integer 
         */
        public function getCodeServiceMilitaire()
        {
            return $this->codeServiceMilitaire;
        }
     
        /**
         * Set libServiceMilitaire
         *
         * @param string $libServiceMilitaire
         */
        public function setLibServiceMilitaire($libServiceMilitaire)
        {
            $this->libServiceMilitaire = $libServiceMilitaire;
        }
     
        /**
         * Get libServiceMilitaire
         *
         * @return string 
         */
        public function getLibServiceMilitaire()
        {
            return $this->libServiceMilitaire;
        }
    }

  11. #11
    Membre éprouvé Avatar de Avrel
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2010
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Avril 2010
    Messages : 118
    Par défaut
    Passe tes strategies en auto :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    @ORM\GeneratedValue(strategy="AUTO")

  12. #12
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    j 'ai le modifier
    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
    <?php
     
    namespace MyApp\emploiBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
     
    /**
     * MyApp\emploiBundle\Entity\PvJobCandInformationsGenerales
     *
     * @ORM\Table(name="pv__job_cand_informations_generales")
     * @ORM\Entity
     */
    class PvJobCandInformationsGenerales
    {
        /**
         * @var integer $id
         *
         * @ORM\Column(name="id_infogenerale", type="integer", nullable=false)
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
     
        /**
         * @var string $permisCand
         *
         * @ORM\Column(name="permis_cand", type="string", length=254, nullable=true)
         */
        private $permisCand;
     
        /**
         * @var string $voitureCand
         *
         * @ORM\Column(name="voiture_cand", type="string", length=254, nullable=true)
         */
        private $voitureCand;
     
        /**
         * @var string $servMilCand
         *
         * @ORM\Column(name="serv_mil_cand", type="string", length=254, nullable=true)
         */
        private $servMilCand;
     
        /**
         * @var PvJobLstServiceMilitaire
         *
         * @ORM\ManyToOne(targetEntity="PvJobLstServiceMilitaire")
         * @ORM\JoinColumns({
         *   @ORM\JoinColumn(name="id_service_militaire", referencedColumnName="id_service_militaire")
         * })
         */
        private $idServiceMilitaire;
     
     
     
        /**
         * Get id
         *
         * @return integer 
         */
        public function getId()
        {
            return $this->id;
        }
     
        /**
         * Set permisCand
         *
         * @param string $permisCand
         */
        public function setPermisCand($permisCand)
        {
            $this->permisCand = $permisCand;
        }
     
        /**
         * Get permisCand
         *
         * @return string 
         */
        public function getPermisCand()
        {
            return $this->permisCand;
        }
     
        /**
         * Set voitureCand
         *
         * @param string $voitureCand
         */
        public function setVoitureCand($voitureCand)
        {
            $this->voitureCand = $voitureCand;
        }
     
        /**
         * Get voitureCand
         *
         * @return string 
         */
        public function getVoitureCand()
        {
            return $this->voitureCand;
        }
     
        /**
         * Set servMilCand
         *
         * @param string $servMilCand
         */
        public function setServMilCand($servMilCand)
        {
            $this->servMilCand = $servMilCand;
        }
     
        /**
         * Get servMilCand
         *
         * @return string 
         */
        public function getServMilCand()
        {
            return $this->servMilCand;
        }
     
        /**
         * Set idServiceMilitaire
         *
         * @param MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire $idServiceMilitaire
         */
        public function setIdServiceMilitaire(\MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire $idServiceMilitaire)
        {
            $this->idServiceMilitaire = $idServiceMilitaire;
        }
     
        /**
         * Get idServiceMilitaire
         *
         * @return MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire 
         */
        public function getIdServiceMilitaire()
        {
            return $this->idServiceMilitaire;
        }
    }
    et lorsque je veux ajouter la deuxième valeur il m 'affiche
    cette erreur

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Propriété "id" n'est pas public dans la classe "MyApp \ emploiBundle \ Entity \ PvJobLstServiceMilitaire". Peut-être que vous devriez créer la méthode "setId ()"?
    j 'ajoute le seteur de ID ?

  13. #13
    Inactif
    Inscrit en
    Novembre 2010
    Messages
    187
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 187
    Par défaut
    j 'ai résolu le problème
    je doit coché AUTO_INCREMENT dans phpmyadmin pour chaque identifiant pour qu 'il fait l ' incrémentation et pour la form
    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
    <?php
     
    namespace MyApp\emploiBundle\Form;
     
    use Symfony\Component\Form\AbstractType;
    use Symfony\Component\Form\FormBuilder;
     
    class PvJobCandInformationsGeneralesType extends AbstractType
    {
        public function buildForm(FormBuilder $builder, array $options)
        {
            $builder
                ->add('permisCand')
                ->add('voitureCand')
                ->add('servMilCand')
                ->add('idServiceMilitaire','entity', array(
                        'class' => 'MyApp\emploiBundle\Entity\PvJobLstServiceMilitaire',
                        'label'=> 'Service Militaire:',
    					'property'=>'libServiceMilitaire'))
            ;
        }
     
        public function getName()
        {
            return 'myapp_emploibundle_pvjobcandinformationsgeneralestype';
        }
    }

  14. #14
    Membre éprouvé Avatar de Avrel
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2010
    Messages
    118
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Avril 2010
    Messages : 118
    Par défaut
    Plutot que de cocher auto_increment dans phpMyAdmin pour chaque id,

    tu aurais pu faire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    php app/console doctrine:schema:update --force
    Si ton problème est résolu, passe le sujet en RESOLU

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

Discussions similaires

  1. [2.x] Erreur ajout annonce symfony2
    Par mustapha_aim dans le forum Symfony
    Réponses: 3
    Dernier message: 12/08/2013, 15h46
  2. Réponses: 3
    Dernier message: 07/01/2013, 22h51
  3. [2.x] [Symfony2]Erreur lors de la création d'un bundle
    Par Philippe PONS dans le forum Symfony
    Réponses: 5
    Dernier message: 13/12/2012, 18h45
  4. [2.x] affichage d'erreur de validation d'un formulaire Symfony2.1
    Par encours dans le forum Symfony
    Réponses: 8
    Dernier message: 06/12/2012, 09h22
  5. [2.x] [Symfony2] Erreur affichage du bundle
    Par tristabeau dans le forum Symfony
    Réponses: 3
    Dernier message: 29/11/2012, 13h32

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