我使用了最新版本的 EasyAdmin,提交表单时忽略了我的add
和remove
函数:
Ambiance
实体:
/**
* @ORM\OneToMany(targetEntity="Vehicule", mappedBy="ambiance")
*/
protected Collection $vehicules;
public function __construct()
{
$this->vehicules = new ArrayCollection();
}
public function addVehicule(Vehicule $vehicule): self
{
if (!$this->vehicules->contains($vehicule)) {
$this->vehicules[] = $vehicule;
$vehicule->setAmbiance($this);
}
return $this;
}
public function removeVehicule(Vehicule $vehicule): void
{
if (!$this->vehicules->contains($vehicule)) {
return;
}
$this->vehicules->removeElement($vehicule);
}
public function getVehicules()
{
return $this->vehicules;
}
public function setVehicules($vehicules): void
{
$this->vehicules = $vehicules;
}
然而我的教义映射是有效的..
我的 EasyAdmin 表格AmbianceCrudController.php
:
'vehicules' => AssociationField::new('vehicules', 'Véhicules'),
它生成一个multiple select2
但是当我添加车辆并提交我的表单时,没有插入任何数据。