2017-01-05 2 views
-5

クラス 'レクラメーション'多対一クラス 'クラス' 私は特定のクラスにレクラメーションを追加したいので、私はデータベースクラスからインポートしようとしましたが、彼はウェブ上で多くを検索し、私は解決策を見つけることができなかったというエラーを私に見せ続けます。Symfony内の別のテーブルから値をインポートする方法

public function buildForm(FormBuilderInterface $builder, array $options) 
{ 
    $builder->add('Matricule')->add('Nom') 
     ->add('Prenom') 
     ->add('Enseignant') 
     ->add('statut',HiddenType::class) 

     ->add('classe',EntityType::class,array(
      'class' => 'ReclamationBundle:Classe', 
      'choice_label'=> 'libelle')) 
     ->add('Motif',TextareaType::class) 
     ->add("Ajouter",SubmitType::class); 

} 

エラー埋め立て用 が、これは私のentitesある クラッセ

<?php 

namespace ReclamationBundle\Entity; 
use Doctrine\ORM\Mapping as ORM; 
/** 
* Class Classe 
* @package ReclamationBundle\Entity 
* @ORM\Entity 
* @ORM\Table(name="Classe") 
*/ 


class Classe 
{ 

/** 
*@ORM\Id 
*@ORM\Column(type="integer") 
* @ORM\GeneratedValue 
* 
*/ 
private $id; 
/** 
* @ORM\Column(type="string",length=255) 
*/ 
private $libelle; 

/** 
* @return mixed 
*/ 
public function getId() 
{ 
    return $this->id; 
} 

/** 
* @param mixed $id 
*/ 
public function setId($id) 
{ 
    $this->id = $id; 
} 

/** 
* @return mixed 
*/ 
public function getLibelle() 
{ 
    return $this->libelle; 
} 

/** 
* @param mixed $libelle 
*/ 
public function setLibelle($libelle) 
{ 
    $this->libelle = $libelle; 
} 

} 

干拓

<?php 

namespace ReclamationBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* Class Reclamation 
* @package ReclamationBundle\Entity 
* @ORM\Entity 
* @ORM\Table(name="Reclamation") 
*/ 
class Reclamation 
{/** 
*@ORM\Id 
*@ORM\Column(type="integer") 
* @ORM\GeneratedValue 
* @ORM\ManyToMany(targetEntity="Classe") 
*/ 
private $Matricule; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 
private $Nom; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 
private $Prenom; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 
private $Enseignant; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 
private $Motif; 
/** 
* @ORM\Column(type="string",length=255) 
* 
*/ 
private $Statut; 

/** 
* @return mixed 
*/ 
public function getMatricule() 
{ 
    return $this->Matricule; 
} 

/** 
* @param mixed $Matricule 
*/ 
public function setMatricule($Matricule) 
{ 
    $this->Matricule = $Matricule; 
} 

/** 
* @return mixed 
*/ 
public function getNom() 
{ 
    return $this->Nom; 
} 

/** 
* @param mixed $Nom 
*/ 
public function setNom($Nom) 
{ 
    $this->Nom = $Nom; 
} 

/** 
* @return mixed 
*/ 
public function getPrenom() 
{ 
    return $this->Prenom; 
} 

/** 
* @param mixed $Prenom 
*/ 
public function setPrenom($Prenom) 
{ 
    $this->Prenom = $Prenom; 
} 

/** 
* @return mixed 
*/ 
public function getEnseignant() 
{ 
    return $this->Enseignant; 
} 

/** 
* @param mixed $Enseignant 
*/ 
public function setEnseignant($Enseignant) 
{ 
    $this->Enseignant = $Enseignant; 
} 

/** 
* @return mixed 
*/ 
public function getMotif() 
{ 
    return $this->Motif; 
} 

/** 
* @param mixed $Motif 
*/ 
public function setMotif($Motif) 
{ 
    $this->Motif = $Motif; 
} 

/** 
* @return mixed 
*/ 
public function getStatut() 
{ 
    return $this->Statut; 
} 

/** 
* @param mixed $Statut 
*/ 
public function setStatut($Statut) 
{ 
    $this->Statut = $Statut; 
} 

} 

ビルドフォーム:getClasse どちらのプロパティ "クラッセ" も方法の一つ」( ) "、" classe() "、" isClasse() "、" hasClasse() "、" __get() "が存在し、クラス" ReclamationBundle \ Entity \ Rec "嘆き "。

+1

(http://stackoverflow.com/help/how-to-ask)[どのように私は良い質問をしてください]お読みください! –

+0

あなたの質問は非常に悪いです。また、無駄です:あなたのReclamationクラスでgetClasse()メソッドが見えますか?私はそうではありませんし、私のようにPHPはそうではありませんので、エラーを知らせます。メソッドgetClasse()を作成する必要があります。また、開発の基本(PHPだけでなく)を学ぶ必要があります。 – Aerendir

+0

私はその上で動作します –

答えて

0

ManyToOneの関係が示唆されますが、これはあなたが必要とするものだと思います。 IDの指定が間違っています。以下の変更を参照してください。 Classeのオブジェクトを格納するにはArrayCollectionが必要です。

私は以下のコードはあなたに考えを与えるべきだと思います。あなたはおそらく、投稿する前にもっと研究をしていたはずです。

class Classe 
{ 
    /** 
    * @ORM\Id 
    * @ORM\Column(name="class_id", type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $class_id; 

    /** 
    * @ORM\ManyToOne(targetEntity="Reclamation", inversedBy="classes") 
    * @ORM\JoinColumn(name="mat_id", referencedColumnName="Matricule") 
    */ 
    protected $student; 

use Doctrine\Common\Collections\ArrayCollection; 
... 
class Reclamation 
{ 
    /* 
    * @ORM\Id 
    * @ORM\Column(name="Matricule", type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $Matricule; 

    /** 
    * @ORM\OneToMany(targetEntity="Classe", mappedBy="reclamation") 
    */ 
    protected $classes = null; 

    /* 
    * The constructor. 
    */ 
    public function __construct(){ 
     // This is an array of classes. 
     $this->classes = new ArrayCollection(); 
    } 
+0

ありがとう、しかし変更なし –

+0

私は実際にそれより多くのフィードバックを必要とします! 'php bin/console doctrine:schema:update --force'を試して、キャッシュ' php bin/console cache:clear --env = prod'もクリアしましたか? –

+0

あなたは私の上記のコメントを見ましたか? –

関連する問題