I use the last version of EasyAdmin and my add
and remove
functions are ignored when I submit the form:
Ambiance
entity:
/**
* @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;
}
Yet my Doctrine mapping is valid..
My EasyAdmin form in AmbianceCrudController.php
:
'vehicules' => AssociationField::new('vehicules', 'Véhicules'),
It generates a multiple select2
but when I add vehicles and submit my form, no data is inserted.