EasyAdmin (Symfony) does not update ManyToOne entities in Association Field with multiple relationships

We have a backoffice developed with EasyAdmin (4.4.5), for a Symfony (5.4.24) project. Among other entities and features, we have a bunch of related entities, as shown in the following code example. The thing is, with these relationships, when we create an entity, everything is working correctly; but when we want to update one of the related entities, this change is not made (everything updates except for the relation).

We have been investigating and we see that EasyAdmin’s CRUD forms sends the new data, and the new values goes through the “setXxxx” functions of the modified entities. But those entities, when they reach the “updateEntity()” function, arrive with the old related data.

Can someone tell us if this situation is due to a bad configuration of the entities, or if there is an error in the code, or if it’s a Symfony or Doctrine cache problem, or if it is a bug in EasyAdmin?

We have not been able to solve this situation.

Thank you so much.

PD: The number “2” in the entities name is because I generated an example of code from our project, simplified to be able to explain the case.

Entities:

// namespace AppModuleAC2EntityManufacturer2;
class Manufacturer2 implements EntityInterface
{
    use IdEntityTrait;
    use NameEntityTrait;

    #[AssertNotNull(message: 'trans.assert.systemRanges.notNull')]
    #[AssertType(type: Collection::class, message: 'trans.assert.systemRanges.type')]
    #[AssertValid]
    #[AssertAll([
        new AssertType([Key::TYPE => SystemRange2::class, Key::MESSAGE => 'trans.assert.systemRanges.all.type'])
    ])]
    #[ORMOneToMany(targetEntity: SystemRange2::class, mappedBy: 'manufacturer', orphanRemoval: true)]
    private Collection $systemRanges;

    #[AssertNotNull(message: 'trans.assert.acModels.notNull')]
    #[AssertType(type: Collection::class, message: 'trans.assert.acModels.type')]
    #[AssertValid]
    #[AssertAll([
        new AssertType([Key::TYPE => ACModel2::class, Key::MESSAGE => 'trans.assert.acModels.all.type'])
    ])]
    #[ORMOneToMany(targetEntity: ACModel2::class, mappedBy: 'manufacturer', orphanRemoval: true)]
    private Collection $acModels;

    public function __construct()
    {
        $this->setId();
        $this->systemRanges = new ArrayCollection();
        $this->acModels     = new ArrayCollection();
    }
...
}
// namespace AppModuleAC2EntitySystemRange2;
class SystemRange2 implements EntityInterface
{
    use IdEntityTrait;
    use NameEntityTrait;

    #[AssertNotNull(message: 'trans.assert.manufacturer.notNull')]
    #[AssertType(type: Manufacturer2::class, message: 'trans.assert.manufacturer.type')]
    #[AssertValid]
    #[ORMManyToOne(targetEntity: Manufacturer2::class, inversedBy: 'systemRanges')]
    #[ORMJoinColumn(nullable: false)]
    private ?Manufacturer2 $manufacturer = null;

    #[AssertNotNull(message: 'trans.assert.lines.notNull')]
    #[AssertType(type: Collection::class, message: 'trans.assert.lines.type')]
    #[AssertValid]
    #[AssertAll([
        new AssertType([Key::TYPE => Line2::class, Key::MESSAGE => 'trans.assert.lines.all.type'])
    ])]
    #[ORMOneToMany(targetEntity: Line2::class, mappedBy: 'systemRange', orphanRemoval: true)]
    private Collection $lines;

    #[AssertNotNull(message: 'trans.assert.acModels.notNull')]
    #[AssertType(type: Collection::class, message: 'trans.assert.acModels.type')]
    #[AssertValid]
    #[AssertAll([
        new AssertType([Key::TYPE => ACModel2::class, Key::MESSAGE => 'trans.assert.acModels.all.type'])
    ])]
    #[ORMOneToMany(targetEntity: ACModel2::class, mappedBy: 'systemRange', orphanRemoval: true)]
    private Collection $acModels;

    public function __construct()
    {
        $this->setId();
        $this->lines    = new ArrayCollection();
        $this->acModels = new ArrayCollection();
    }
...
}
// namespace AppModuleAC2EntityLine2;
class Line2 implements EntityInterface
{
    use IdEntityTrait;
    use NameEntityTrait;

    #[AssertNotNull(message: 'trans.assert.systemRange.notNull')]
    #[AssertType(type: SystemRange2::class, message: 'trans.assert.systemRange.type')]
    #[AssertValid]
    #[ORMManyToOne(targetEntity: SystemRange2::class, inversedBy: 'lines')]
    #[ORMJoinColumn(nullable: false)]
    private ?SystemRange2 $systemRange = null;

    #[AssertNotNull(message: 'trans.assert.acModels.notNull')]
    #[AssertType(type: Collection::class, message: 'trans.assert.acModels.type')]
    #[AssertValid]
    #[AssertAll([
        new AssertType([Key::TYPE => ACModel2::class, Key::MESSAGE => 'trans.assert.acModels.all.type'])
    ])]
    #[ORMOneToMany(targetEntity: ACModel2::class, mappedBy: 'line', orphanRemoval: true)]
    private Collection $acModels;

    public function __construct()
    {
        $this->setId();
        $this->acModels = new ArrayCollection();
    }
...
}
// namespace AppModuleAC2EntityACModel2;
class ACModel2 implements EntityInterface
{
    use IdEntityTrait;
    use NameEntityTrait;

    #[AssertNotNull(message: 'trans.assert.systemRange.notNull')]
    #[AssertType(type: SystemRange2::class, message: 'trans.assert.systemRange.type')]
    #[AssertValid]
    #[ORMManyToOne(targetEntity: SystemRange2::class, inversedBy: 'acModels')]
    #[ORMJoinColumn(nullable: false)]
    private ?SystemRange2 $systemRange = null;

    #[AssertNotNull(message: 'trans.assert.line.notNull')]
    #[AssertType(type: Line2::class, message: 'trans.assert.line.type')]
    #[AssertValid]
    #[ORMManyToOne(targetEntity: Line2::class, inversedBy: 'acModels')]
    #[ORMJoinColumn(nullable: false)]
    private ?Line2 $line = null;

    #[AssertNotNull(message: 'trans.assert.manufacturer.notNull')]
    #[AssertType(type: Manufacturer2::class, message: 'trans.assert.manufacturer.type')]
    #[AssertValid]
    #[ORMManyToOne(targetEntity: Manufacturer2::class, inversedBy: 'acModels')]
    #[ORMJoinColumn(nullable: false)]
    private ?Manufacturer2 $manufacturer = null;

    public function __construct()
    {
        $this->setId();
    }
...
}

Workflow in images:

Define manufacturers

Define SystemRange

Define Line

Define ACModel

Try to update Manufacturer in ACModel

We have tried: Check the circular references of the entities, configure the Symfony and Doctrine cache so that it does not run, keep track of the value changes in the entities, we have also tried to remove some of the relations of the entities (just for testing), …

We expected that you could change any of the related entities, and save the change normally from EasyAdmin.