Bonjour,
Je reviens avec un nouveau problème.
Un utlisateur propose une idée. J'ai donc une page avec toute les idées et je voudrai afficher le nom de l'utilisateur qui a affiché l'idée masi j'obtiens l'erreur suivante.
J'ai donc fait un
{{ idee.utilisateur.username }}
dans mon template
An exception has been thrown during the rendering of a template ("Notice: Undefined index: targetToSourceKeyColumns in C:\wamp\www\Democratie\vendor\doctrine\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php line 1281")
Voici mes entités
Utilisateur
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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
| <?php
namespace Demo\UtilisateurBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class Utilisateur extends BaseUser {
/**
* @ORM\OneToMany(targetEntity="Demo\ArbreBundle\Entity\Commentaire", mappedBy="utilisateur")
*/
private $commentaire;
/**
* @ORM\OneToMany(targetEntity="Demo\ArbreBundle\Entity\Note", mappedBy="utilisateur")
*/
private $note;
/**
* @ORM\OneToMany(targetEntity="Demo\ArbreBundle\Entity\Idee", mappedBy="utilisateur")
*/
private $idee;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\generatedValue(strategy="AUTO")
*/
protected $id;
// Ajoutez vos attributs ici, un attribut *location* de type *text* pour notre exemple :
/**
* @ORM\Column(type="string", nullable="true")
*/
protected $nom;
/**
* @ORM\Column(type="string", nullable="true")
*/
protected $prenom;
/**
* @ORM\Column(type="string", nullable="true")
*/
protected $ville;
/**
* @ORM\Column(type="date", nullable="true")
*/
protected $age;
public function __construct() {
parent::__construct();
}
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Set nom
*
* @param text $nom
*/
public function setNom($nom) {
$this->nom = $nom;
}
/**
* Get nom
*
* @return text
*/
public function getNom() {
return $this->nom;
}
/**
* Set prenom
*
* @param text $prenom
*/
public function setPrenom($prenom) {
$this->prenom = $prenom;
}
/**
* Get prenom
*
* @return text
*/
public function getPrenom() {
return $this->prenom;
}
/**
* Set age
*
* @param text $age
*/
public function setAge($age) {
$this->age = $age;
}
/**
* Get age
*
* @return text
*/
public function getAge() {
return $this->age;
}
/**
* Set ville
*
* @param string $ville
*/
public function setVille($ville) {
$this->ville = $ville;
}
/**
* Get ville
*
* @return string
*/
public function getVille() {
return $this->ville;
}
/**
* Set id
*
* @param integer $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* Add commentaire
*
* @param Demo\ArbreBundle\Entity\Commentaire $commentaire
*/
public function addCommentaire(\Demo\ArbreBundle\Entity\Commentaire $commentaire)
{
$this->commentaire[] = $commentaire;
}
/**
* Get commentaire
*
* @return Doctrine\Common\Collections\Collection
*/
public function getCommentaire()
{
return $this->commentaire;
}
/**
* Add note
*
* @param Demo\ArbreBundle\Entity\Note $note
*/
public function addNote(\Demo\ArbreBundle\Entity\Note $note)
{
$this->note[] = $note;
}
/**
* Get note
*
* @return Doctrine\Common\Collections\Collection
*/
public function getNote()
{
return $this->note;
}
/**
* Add idee
*
* @param Demo\ArbreBundle\Entity\Idee $idee
*/
public function addIdee(\Demo\ArbreBundle\Entity\Idee $idee)
{
$this->idee[] = $idee;
}
/**
* Get idee
*
* @return Doctrine\Common\Collections\Collection
*/
public function getIdee()
{
return $this->idee;
}
} |
Propose
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
| <?php
namespace Demo\ArbreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*/
class Propose {
/**
* @ORM\ManyToOne(targetEntity="Demo\ArbreBundle\Entity\Idee")
* @ORM\JoinColumn(name="idee", referencedColumnName="id", onDelete="CASCADE", onUpdate="CASCADE", nullable=true)
* @ORM\Id
*/
private $idee;
/**
* @ORM\ManyToOne(targetEntity="Demo\UtilisateurBundle\Entity\Utilisateur")
* @ORM\JoinColumn(name="utilisateur", referencedColumnName="id", onDelete="CASCADE", onUpdate="CASCADE", nullable=true)
* @ORM\Id
*/
private $utilisateur;
/**
* @ORM\Column(type="date")
* @Assert\NotBlank()
*/
protected $date;
public function __construct() {
$this->date = new \DateTime();
}
/**
* Set date
*
* @param date $date
*/
public function setDate($date) {
$this->date = $date;
}
/**
* Get date
*
* @return date
*/
public function getDate() {
return $this->date;
}
/**
* Set idee
*
* @param Demo\ArbreBundle\Entity\Idee $idee
*/
public function setIdee(\Demo\ArbreBundle\Entity\Idee $idee) {
$this->idee = $idee;
}
/**
* Get idee
*
* @return Demo\ArbreBundle\Entity\Idee
*/
public function getIdee() {
return $this->idee;
}
/**
* Set utilisateur
*
* @param Demo\UtilisateurBundle\Entity\Utilisateur $utilisateur
*/
public function setUtilisateur(\Demo\UtilisateurBundle\Entity\Utilisateur $utilisateur) {
$this->utilisateur = $utilisateur;
}
/**
* Get utilisateur
*
* @return Demo\UtilisateurBundle\Entity\Utilisateur
*/
public function getUtilisateur() {
return $this->utilisateur;
}
} |
idée
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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
| <?php
namespace Demo\ArbreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Demo\ArbreBundle\Entity\Note;
/**
* @ORM\Entity
*/
class Idee {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\generatedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\OneToMany(targetEntity="Demo\ArbreBundle\Entity\Commentaire", mappedBy="idee")
*/
private $commentaire;
/**
* @ORM\OneToMany(targetEntity="Demo\ArbreBundle\Entity\Note", mappedBy="idee")
*/
private $note;
/**
* @ORM\OneToMany(targetEntity="Demo\UtilisateurBundle\Entity\Utilisateur", mappedBy="idee")
*/
private $utilisateur;
/**
* @ORM\ManyToOne(targetEntity="Theme", inversedBy="idee")
* @ORM\JoinColumn(name="theme", referencedColumnName="id", onDelete="CASCADE", onUpdate="CASCADE", nullable=true)
*/
private $theme;
/**
* @ORM\Column(type="string",length="255")
* @Assert\NotBlank()
* @Assert\MinLength(3)
*/
private $libelle;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\Column(type="integer")
* @Assert\NotBlank()
*/
private $etat;
public function __toString() {
return $this->theme;
}
public function __construct() {
$this->commentaire = new \Doctrine\Common\Collections\ArrayCollection();
$this->note = new \Doctrine\Common\Collections\ArrayCollection();
$this->utilisateur = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Set libelle
*
* @param string $libelle
*/
public function setLibelle($libelle) {
$this->libelle = $libelle;
}
/**
* Get libelle
*
* @return string
*/
public function getLibelle() {
return $this->libelle;
}
/**
* Set description
*
* @param text $description
*/
public function setDescription($description) {
$this->description = $description;
}
/**
* Get description
*
* @return text
*/
public function getDescription() {
return $this->description;
}
/**
* Set etat
*
* @param integer $etat
*/
public function setEtat($etat) {
$this->etat = $etat;
}
/**
* Get etat
*
* @return integer
*/
public function getEtat() {
return $this->etat;
}
/**
* Add commentaire
*
* @param Demo\ArbreBundle\Entity\Commentaire $commentaire
*/
public function addCommentaire(\Demo\ArbreBundle\Entity\Commentaire $commentaire) {
$this->commentaire[] = $commentaire;
}
/**
* Get commentaire
*
* @return Doctrine\Common\Collections\Collection
*/
public function getCommentaire() {
return $this->commentaire;
}
/**
* Add note
*
* @param Demo\ArbreBundle\Entity\Note $note
*/
public function addNote(\Demo\ArbreBundle\Entity\Note $note) {
$this->note[] = $note;
}
/**
* Get note
*
* @return Doctrine\Common\Collections\Collection
*/
public function getNote() {
return $this->note;
}
/**
* Add utilisateur
*
* @param Demo\UtilisateurBundle\Entity\Utilisateur $utilisateur
*/
public function addUtilisateur(\Demo\UtilisateurBundle\Entity\Utilisateur $utilisateur) {
$this->utilisateur[] = $utilisateur;
}
/**
* Get utilisateur
*
* @return Doctrine\Common\Collections\Collection
*/
public function getUtilisateur() {
return $this->utilisateur;
}
/**
* Set theme
*
* @param Demo\ArbreBundle\Entity\Theme $theme
*/
public function setTheme(\Demo\ArbreBundle\Entity\Theme $theme) {
$this->theme = $theme;
}
/**
* Get theme
*
* @return Demo\ArbreBundle\Entity\Theme
*/
public function getTheme() {
return $this->theme;
}
} |
Et ma fonction pour lister les idées etc
1 2 3 4 5 6 7 8 9 10 11
| public function Liste_Theme_ParentAction($parent) {
$em = $this->getDoctrine()->getEntityManager();
$entities = $em->getRepository('DemoArbreBundle:Theme')->findBy(array('parent' => $parent));
$idees = $em->getRepository('DemoArbreBundle:Idee')->findBy(array('theme' => $parent));
return $this->render('DemoArbreBundle::arbre_classique.html.twig', array(
'entities' => $entities,
'idees' => $idees,
));
} |
Merci de votre aide
Partager