La Ferme du web - Les forums

Venez baraguiner avec la communauté !

Vous n'êtes pas identifié.

#1 14/02/2012 19:39:41

cbtraize42
Membre
Date d'inscription: 14/02/2012
Messages: 1

Symfony 2 : Formulaire

Bonjour,

Je suis vraiment bloquer sur quelque chose de surement tout bête je vous explique.
Je travail sur un système de gestion de bourse aux livres pour l'obtention de mon BTS IRIS. et donc je doit travailler avec le framework Symfony 2.

Le soucis intervient à la 2ème étape de mon système la première étant que l'opérateur effectue une recherche d'un élève et clique ensuite sur visualiser la fiche pour vérifier les informations personnels sur l'élève donc sa classe et options ainsi que les informations sur le responsable légal.

C'est sur ce formulaire que j'ai un soucis   

Car je n'est réussi qu'a afficher les champs concernant l'élève soit Nom, Prénom, et Date de Naissance grâce à l'entité "Eleve" moi je souhaite rajouté les champs de l'entité "Parents" qui regroupe Nom prénom adresse ville cp et email. et c'est exactement ça mon problème !

voici mon code :

Mon Controlleur VenteController.php :

Code:

    public function ficheEleveAction($id)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entity = $em->getRepository('LGBBourseLivresBundle:Eleve')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException("L'élève n'existe pas !");
        }

        $editForm = $this->createForm(new EleveType(), $entity);
        $deleteForm = $this->createDeleteForm($id);



        return $this->render('LGBBourseLivresBundle:Vente:fiche.html.twig', array(
            'Eleve'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }

Routing

Code:

LGBBourseLivresBundle_home_vente_fiche:
    pattern: /vente/fiche/{id}
    defaults: { _controller: LGBBourseLivresBundle:Vente:ficheEleve}

Entité Eleve :

Code:

<?php

namespace LGB\BourseLivresBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

use Symfony\Component\Validator\Constraints as Assert;

/**
 * LGB\BourseLivresBundle\Entity\Eleve
 *
 * @ORM\Table(name="eleve")
 * @ORM\Entity(repositoryClass="LGB\BourseLivresBundle\Entity\EleveRepository")
 */
class Eleve
{
    /**
     * @var integer $ideleve
     *
     * @ORM\Column(name="ideleve", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $ideleve;

    /**
     * @var string $nom
     *
     * @ORM\Column(name="nom", type="string", length=30, nullable=false)
     */
    private $nom;

    /**
     * @var string $prenom
     * 
     * @ORM\Column(name="prenom", type="string", length=30, nullable=false)
     */
    private $prenom;

    /**
     * @var date $dateNaissance
     * 
     * @ORM\Column(name="date_naissance", type="date", nullable=false)
     */
    private $dateNaissance;

    /**
     * @var Options
     *
     * @ORM\ManyToMany(targetEntity="Options", inversedBy="eleveeleve")
     * @ORM\JoinTable(name="eleve_has_options",
     *   joinColumns={
     *     @ORM\JoinColumn(name="eleve_ideleve", referencedColumnName="ideleve")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="options_idoption", referencedColumnName="idoption")
     *   }
     * )
     */
    private $optionsoption;

    /**
     * @var Classe
     *
     * @ORM\ManyToOne(targetEntity="Classe")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="classe_idclasse", referencedColumnName="idclasse")
     * })
     */
    private $classeclasse;

    /**
     * @var Parents
     *
     * @ORM\ManyToOne(targetEntity="Parents")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="parent_idparent", referencedColumnName="idparent")
     * })
     */
    private $parentparent;

    public function __construct()
    {
        $this->optionsoption = new \Doctrine\Common\Collections\ArrayCollection();
    }
    

    /**
     * Get ideleve
     *
     * @return integer 
     */
    public function getIdeleve()
    {
        return $this->ideleve;
    }

    /**
     * Set nom
     *
     * @param string $nom
     */
    public function setNom($nom)
    {
        $this->nom = $nom;
    }

    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set prenom
     *
     * @param string $prenom
     */
    public function setPrenom($prenom)
    {
        $this->prenom = $prenom;
    }

    /**
     * Get prenom
     *
     * @return string 
     */
    public function getPrenom()
    {
        return $this->prenom;
    }

    /**
     * Set dateNaissance
     *
     * @param date $dateNaissance
     */
    public function setDateNaissance($dateNaissance)
    {
        $this->dateNaissance = $dateNaissance;
    }

    /**
     * Get dateNaissance
     *
     * @return date 
     */
    public function getDateNaissance()
    {
        return $this->dateNaissance;
    }

    /**
     * Add optionsoption
     *
     * @param LGB\BourseLivresBundle\Entity\Options $optionsoption
     */
    public function addOptions(\LGB\BourseLivresBundle\Entity\Options $optionsoption)
    {
        $this->optionsoption[] = $optionsoption;
    }

    /**
     * Get optionsoption
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getOptionsoption()
    {
        return $this->optionsoption;
    }

    /**
     * Set classeclasse
     *
     * @param LGB\BourseLivresBundle\Entity\Classe $classeclasse
     */
    public function setClasseclasse(\LGB\BourseLivresBundle\Entity\Classe $classeclasse)
    {
        $this->classeclasse = $classeclasse;
    }

    /**
     * Get classeclasse
     *
     * @return LGB\BourseLivresBundle\Entity\Classe 
     */
    public function getClasseclasse()
    {
        return $this->classeclasse;
    }

    /**
     * Set parentparent
     *
     * @param LGB\BourseLivresBundle\Entity\Parents $parentparent
     */
    public function setParentparent(\LGB\BourseLivresBundle\Entity\Parents $parentparent)
    {
        $this->parentparent = $parentparent;
    }

    /**
     * Get parentparent
     *
     * @return LGB\BourseLivresBundle\Entity\Parents 
     */
    public function getParentparent()
    {
        return $this->parentparent;
    }
}

Entité Parents :

Code:

<?php

namespace LGB\BourseLivresBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * LGB\BourseLivresBundle\Entity\Parents
 *
 * @ORM\Table(name="parents")
 * @ORM\Entity(repositoryClass="LGB\BourseLivresBundle\Entity\ParentsRepository")
 */
class Parents
{
    /**
     * @var integer $idparent
     *
     * @ORM\Column(name="idparent", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $idparent;

    /**
     * @var string $nom
     *
     * @ORM\Column(name="nom", type="string", length=30, nullable=false)
     */
    private $nom;

    /**
     * @var string $prenom
     *
     * @ORM\Column(name="prenom", type="string", length=30, nullable=false)
     */
    private $prenom;

    /**
     * @var string $adresse
     *
     * @ORM\Column(name="adresse", type="string", length=50, nullable=false)
     */
    private $adresse;

    /**
     * @var string $cp
     *
     * @ORM\Column(name="cp", type="string", length=8, nullable=false)
     */
    private $cp;

    /**
     * @var string $ville
     *
     * @ORM\Column(name="ville", type="string", length=30, nullable=false)
     */
    private $ville;

    /**
     * @var decimal $cotisation
     *
     * @ORM\Column(name="cotisation", type="decimal", nullable=true)
     */
    private $cotisation;

    /**
     * @var string $telephoneFixe
     *
     * @ORM\Column(name="telephone_fixe", type="string", length=20, nullable=true)
     */
    private $telephoneFixe;

    /**
     * @var string $mobile
     *
     * @ORM\Column(name="mobile", type="string", length=20, nullable=true)
     */
    private $mobile;

    /**
     * @var boolean $cotisationPaye
     *
     * @ORM\Column(name="cotisation_paye", type="boolean", nullable=true)
     */
    private $cotisationPaye;

    /**
     * @var Credit
     *
     * @ORM\ManyToOne(targetEntity="Credit")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="credit_idcredit", referencedColumnName="idcredit")
     * })
     */
    private $creditcredit;



    /**
     * Get idparent
     *
     * @return integer 
     */
    public function getIdparent()
    {
        return $this->idparent;
    }

    /**
     * Set nom
     *
     * @param string $nom
     */
    public function setNom($nom)
    {
        $this->nom = $nom;
    }

    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set prenom
     *
     * @param string $prenom
     */
    public function setPrenom($prenom)
    {
        $this->prenom = $prenom;
    }

    /**
     * Get prenom
     *
     * @return string 
     */
    public function getPrenom()
    {
        return $this->prenom;
    }

    /**
     * Set adresse
     *
     * @param string $adresse
     */
    public function setAdresse($adresse)
    {
        $this->adresse = $adresse;
    }

    /**
     * Get adresse
     *
     * @return string 
     */
    public function getAdresse()
    {
        return $this->adresse;
    }

    /**
     * Set cp
     *
     * @param string $cp
     */
    public function setCp($cp)
    {
        $this->cp = $cp;
    }

    /**
     * Get cp
     *
     * @return string 
     */
    public function getCp()
    {
        return $this->cp;
    }

    /**
     * Set ville
     *
     * @param string $ville
     */
    public function setVille($ville)
    {
        $this->ville = $ville;
    }

    /**
     * Get ville
     *
     * @return string 
     */
    public function getVille()
    {
        return $this->ville;
    }

    /**
     * Set cotisation
     *
     * @param decimal $cotisation
     */
    public function setCotisation($cotisation)
    {
        $this->cotisation = $cotisation;
    }

    /**
     * Get cotisation
     *
     * @return decimal 
     */
    public function getCotisation()
    {
        return $this->cotisation;
    }

    /**
     * Set telephoneFixe
     *
     * @param string $telephoneFixe
     */
    public function setTelephoneFixe($telephoneFixe)
    {
        $this->telephoneFixe = $telephoneFixe;
    }

    /**
     * Get telephoneFixe
     *
     * @return string 
     */
    public function getTelephoneFixe()
    {
        return $this->telephoneFixe;
    }

    /**
     * Set mobile
     *
     * @param string $mobile
     */
    public function setMobile($mobile)
    {
        $this->mobile = $mobile;
    }

    /**
     * Get mobile
     *
     * @return string 
     */
    public function getMobile()
    {
        return $this->mobile;
    }

    /**
     * Set cotisationPaye
     *
     * @param boolean $cotisationPaye
     */
    public function setCotisationPaye($cotisationPaye)
    {
        $this->cotisationPaye = $cotisationPaye;
    }

    /**
     * Get cotisationPaye
     *
     * @return boolean 
     */
    public function getCotisationPaye()
    {
        return $this->cotisationPaye;
    }

    /**
     * Set creditcredit
     *
     * @param LGB\BourseLivresBundle\Entity\Credit $creditcredit
     */
    public function setCreditcredit(\LGB\BourseLivresBundle\Entity\Credit $creditcredit)
    {
        $this->creditcredit = $creditcredit;
    }

    /**
     * Get creditcredit
     *
     * @return LGB\BourseLivresBundle\Entity\Credit 
     */
    public function getCreditcredit()
    {
        return $this->creditcredit;
    }
}

Merci de votre aide !

Dernière modification par cbtraize42 (14/02/2012 19:41:57)

Hors ligne

 

14/02/2012 19:39:41

Botte De Foin Publicitaire


Pied de page des forums

Powered by FluxBB
© Copyright 2008-2009 - LaFermeduWeb.net