0

首先,我是 Symfony4 的法语初学者,其次,我已经在 Symfony 文档中搜索过,问了一些朋友,叫我妈妈..

我正在编辑/新实体表单上的 EasyAdminBundle 上工作。

我必须更改实体的标签,但是当我这样做时,我的表单类型正在改变。

这是我在编辑前的视图图片:

我有的

我想将 'id_equipe' 更改为 'Domicile (home for English )' 和 id_equipe_equipes 更改为 'exterieur (Visitors)'

所以当我尝试这个时:

 fields:
     - { property: 'id_equipe', label: equipe_domicile}
     - { property: 'id_equipe_equipes', label: equipe_extérieur}

属性的类型正在更改为 TextArea ,我不知道为什么。

我试图放置一个这样的新类型:

 - { property: 'id_equipe', label: equipe_domicile, type: 'choice'}

但我select是空白的,我无法选择任何东西。

这就是我得到的:

我得到了什么

谢谢你们

ps:对不起十年英语

4

2 回答 2

1

所以,看,如果我理解正确的话 -id_equipe是外部实体的关键。因此,通过这种方式,要使其正常工作 - 您需要使用type: 'entity'并添加type_options选项,如下所示:

- { property: 'id_equipe', label: 'Domicile', type: 'entity', type_options: { class: 'App\Entity\Equipe', multiple: true } }

更新:

所以,由于讨论发现问题出在属性命名上。property: 'idEquipe'没有的权利property: 'id_equipe'。因此属性名称必须与实体中的名称相同,而不是与数据库中的字段名称相同。

于 2019-03-19T18:56:35.060 回答
0

这是我的 Matchs 实体。

<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * Matchs
 *
 * @ORM\Table(name="matchs", indexes={@ORM\Index(name="MATCHS_EQUIPES1_FK", columns={"ID_EQUIPE_EQUIPES"}), @ORM\Index(name="MATCHS_EQUIPES_FK", columns={"ID_EQUIPE"}), @ORM\Index(name="MATCHS_JOURNEE0_FK", columns={"ID_JOURNEE"})})
 * @ORM\Entity
 */
class Matchs
{
    /**
     * @var int
     *
     * @ORM\Column(name="ID_MATCHS", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $idMatchs;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="DATE_MATCHS", type="datetime", nullable=false)
     */
    private $dateMatchs;

    /**
     * @var string|null
     *
     * @ORM\Column(name="RESUME_MATCHS", type="text", length=65535, nullable=true)
     */
    private $resumeMatchs;

     /**
     * @var string|null
     *
     * @ORM\Column(name="TITRE_MATCH", type="string", length=255, nullable=true)
     */
    private $titreMatch;

    /**
     * @var int
     *
     * @ORM\Column(name="SCORE_EQUIPE1", type="integer", nullable=false)
     */
    private $scoreEquipe1;

    /**
     * @var int
     *
     * @ORM\Column(name="SCORE_EQUIPE2", type="integer", nullable=false)
     */
    private $scoreEquipe2;

    /**
     * @var \Equipes
     *
     * @ORM\ManyToOne(targetEntity="Equipes")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="ID_EQUIPE_EQUIPES", referencedColumnName="ID_EQUIPE")
     * })
     */
    private $idEquipeEquipes;

    /**
     * @var \Equipes
     *
     * @ORM\ManyToOne(targetEntity="Equipes")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="ID_EQUIPE", referencedColumnName="ID_EQUIPE")
     * })
     */
    private $idEquipe;

    /**
     * @var \Journee
     *
     * @ORM\ManyToOne(targetEntity="Journee")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="ID_JOURNEE", referencedColumnName="ID_JOURNEE")
     * })
     */
    private $idJournee;

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="JoueursEquipe", inversedBy="idMatchs")
     * @ORM\JoinTable(name="jouer",
     *   joinColumns={
     *     @ORM\JoinColumn(name="ID_MATCHS", referencedColumnName="ID_MATCHS")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="ID_JOUEUR_EQUIPE", referencedColumnName="ID_JOUEUR_EQUIPE")
     *   }
     * )
     */
    private $idJoueurEquipe;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->idJoueurEquipe = new \Doctrine\Common\Collections\ArrayCollection();
    }

    public function getIdMatchs()
    {
        return $this->idMatchs;
    }

    public function setIdMatchs(int $idMatchs)
    {
        $this->idMatchs = $idMatchs;

        return $this;
    }

    /**
     * Get the value of dateMatchs
     *
     * @return  \DateTime
     */ 
    public function getDateMatchs()
    {
        return $this->dateMatchs;
    }

    /**
     * Set the value of dateMatchs
     *
     * @param  \DateTime  $dateMatchs
     *
     * @return  self
     */ 
    public function setDateMatchs(\DateTime $dateMatchs)
    {
        $this->dateMatchs = $dateMatchs;

        return $this;
    }

    /**
     * Get the value of resumeMatchs
     *
     * @return  string|null
     */ 
    public function getResumeMatchs()
    {
        return $this->resumeMatchs;
    }

    /**
     * Set the value of resumeMatchs
     *
     * @param  string|null  $resumeMatchs
     *
     * @return  self
     */ 
    public function setResumeMatchs($resumeMatchs)
    {
        $this->resumeMatchs = $resumeMatchs;

        return $this;
    }

    /**
     * Get the value of scoreEquipe1
     *
     * @return  int
     */ 
    public function getScoreEquipe1()
    {
        return $this->scoreEquipe1;
    }

    /**
     * Set the value of scoreEquipe1
     *
     * @param  int  $scoreEquipe1
     *
     * @return  self
     */ 
    public function setScoreEquipe1(int $scoreEquipe1)
    {
        $this->scoreEquipe1 = $scoreEquipe1;

        return $this;
    }

    /**
     * Get the value of scoreEquipe2
     *
     * @return  int
     */ 
    public function getScoreEquipe2()
    {
        return $this->scoreEquipe2;
    }

    /**
     * Set the value of scoreEquipe2
     *
     * @param  int  $scoreEquipe2
     *
     * @return  self
     */ 
    public function setScoreEquipe2(int $scoreEquipe2)
    {
        $this->scoreEquipe2 = $scoreEquipe2;

        return $this;
    }

    /**
     * Get the value of idEquipeEquipes
     *
     * @return  \Equipes
     */ 
    public function getIdEquipeEquipes()
    {
        return $this->idEquipeEquipes;
    }

    /**
     * Set the value of idEquipeEquipes
     *
     * @param  \Equipes  $idEquipeEquipes
     *
     * @return  self
     */ 
    public function setIdEquipeEquipes(\Equipes $idEquipeEquipes)
    {
        $this->idEquipeEquipes = $idEquipeEquipes;

        return $this;
    }

    /**
     * Get the value of idEquipe
     *
     * @return  \Equipes
     */ 
    public function getIdEquipe()
    {
        return $this->idEquipe;
    }

    /**
     * Set the value of idEquipe
     *
     * @param  \Equipes  $idEquipe
     *
     * @return  self
     */ 
    public function setIdEquipe(\Equipes $idEquipe)
    {
        $this->idEquipe = $idEquipe;

        return $this;
    }
    
    public function __toString()
    {
        return $this->nomEquipe;
    }

    /**
     * Get the value of idJournee
     *
     * @return  \Journee
     */ 
    public function getIdJournee()
    {
        return $this->idJournee;
    }

    /**
     * Set the value of idJournee
     *
     * @param  \Journee  $idJournee
     *
     * @return  self
     */ 
    public function setIdJournee(\Journee $idJournee)
    {
        $this->idJournee = $idJournee;

        return $this;
    }

    public function getTitreMatch(): ?string
    {
        return $this->titreMatch;
    }

    public function setTitreMatch(string $titreMatch): self
    {
        $this->titreMatch = $titreMatch;

        return $this;
    }

    /**
     * Get the value of idJoueurEquipe
     *
     * @return  \Doctrine\Common\Collections\Collection
     */ 
    public function getIdJoueurEquipe()
    {
        return $this->idJoueurEquipe;
    }

    /**
     * Set the value of idJoueurEquipe
     *
     * @param  \Doctrine\Common\Collections\Collection  $idJoueurEquipe
     *
     * @return  self
     */ 
    public function setIdJoueurEquipe(\Doctrine\Common\Collections\Collection $idJoueurEquipe)
    {
        $this->idJoueurEquipe = $idJoueurEquipe;

        return $this;
    }

    public function addIdJoueurEquipe(JoueursEquipe $idJoueurEquipe): self
    {
        if (!$this->idJoueurEquipe->contains($idJoueurEquipe)) {
            $this->idJoueurEquipe[] = $idJoueurEquipe;
        }

        return $this;
    }

    public function removeIdJoueurEquipe(JoueursEquipe $idJoueurEquipe): self
    {
        if ($this->idJoueurEquipe->contains($idJoueurEquipe)) {
            $this->idJoueurEquipe->removeElement($idJoueurEquipe);
        }

        return $this;
    }
}

于 2019-03-20T07:21:48.207 回答