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 :

passe un tableau sens form


Sujet :

Symfony PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    131
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 131
    Par défaut passe un tableau sens form
    bonjour j'ai un tableau
    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
    (array) [Number of elements: 2]
    0: 
    (array) [Number of elements: 9]
    nom: (string) lefebvre
    prenom: (string) Jean Claude
    fonction: (string) dz
    codebar: (string) 1
    email: (string) nlefebvre@gmx.fr
    lang: (string) dz
    pays: (string) zd
    choix: (string) dz
    hebergement: (string) 1
    1: 
    (array) [Number of elements: 9]
    nom: (string) lefebvre
    prenom: (string) nicolas
    fonction: (string) dz
    codebar: (string) 1
    email: (string) nlefebvre@gmx.fr
    lang: (string) zd
    pays: (string) zd
    choix: (string) dz
    hebergement: (string) 1
    $parti = au tableau dessus
    je veux le passé en relation :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $matable->addParticipant( $parti);
    dans $matable j'ai:
    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
     
     
        /**
         *
         * @ORM\OneToMany(targetEntity="AppBundle\Entity\Participants",mappedBy="accreditation",  cascade={"persist", "remove"})
         */
        protected $participants;  
        /**
         * Constructor
         */
        public function __construct()
        {
            $this->participants = new \Doctrine\Common\Collections\ArrayCollection();
        }
      /**
         * Get participants
         *
         * @return \Doctrine\Common\Collections\Collection 
         */
        public function getParticipants()
        {
            return $this->participants;
        }
     
     /**
         * Add participants
         *
         * @param \AppBundle\Entity\Participants $participants
         * @return Accreditation
         */
        public function addParticipant(\AppBundle\Entity\Participants $participants)
        {
            $this->participants[] = $participants;
     
            return $this;
        }
     
        /**
         * Remove participants
         *
         * @param \AppBundle\Entity\Participants $participants
         */
        public function removeParticipant(\AppBundle\Entity\Participants $participants)
        {
            $this->participants->removeElement($participants);
        }
    c'est essayer plusieur chose passé un array de 'Participants' mais sa dit qui intense pas 'Participants'
    bref merci de votre aide

  2. #2
    Membre extrêmement actif
    Avatar de dukoid
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2012
    Messages
    2 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2012
    Messages : 2 100
    Par défaut
    tu as :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
      public function addParticipant(\AppBundle\Entity\Participants $participants)
    et tu fais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $matable->addParticipant( $parti);
    $parti est un array et donc

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    131
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 131
    Par défaut
    j'ai essayer
    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
      public function ArrayParticipants($c)
        {
     
                $participants = new Participants(
                    $c['nom'],
                    $c['prenom'],
                    $c['codebar'],
                    $c['email'],
                    $c['lang'],
                    $c['pays'],
                    $c['choix'],
                    $c['hebergement'],
                    $this
                );
     
     
     
            return   $participants ;
        }
    ta pas une solution ?

  4. #4
    Membre extrêmement actif
    Avatar de dukoid
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2012
    Messages
    2 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2012
    Messages : 2 100
    Par défaut
    et bien quoi ? dois je deviner l'erreur ? le problème ?


    et puis :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
     public function addParticipant(\AppBundle\Entity\Participants $participants)
    pourquoi avoir mis un s à Participants ?
    cela représente une entité, un objet... donc sans S

    et tu ajoutes un $participant pas un $participants

    "s" pas 's' ça mène à des confusions... on met un 's' que pour une liste, quand il y en a plusieurs

Discussions similaires

  1. [Débutant C#]tableau sur form
    Par brv1guizmo dans le forum Windows Forms
    Réponses: 1
    Dernier message: 07/05/2008, 16h25
  2. Réponses: 2
    Dernier message: 03/11/2007, 11h24
  3. Passé un tableau dans un formulaire et le récupérer
    Par Alexandre T dans le forum Struts 1
    Réponses: 10
    Dernier message: 23/07/2007, 08h30
  4. [Besoin d'aide] passé un attribut de form en form
    Par toulouseadr dans le forum Windows Forms
    Réponses: 1
    Dernier message: 14/03/2007, 09h24
  5. Comment passé des tableau d'une page a l'autre
    Par kaygee dans le forum Langage
    Réponses: 20
    Dernier message: 08/01/2006, 23h26

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