Open
Description
Symfony version(s) affected
7.3
Description
Having enable_native_lazy_objects = true
and saving a form, even without changes, the related entity is updated with invalid data.
While saving, an SQL statement with UPDATE related_entity SET field1 = NULL, field2 = NULL WHERE id = [ID of related entity];
is executed.
How to reproduce
Two entities, one with a form, the other one as target of an EntityType
:
// Product.php
#[ORM\ManyToOne(inversedBy: 'products')]
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?Vendor $vendor = null;
// Vendor.php
/** @var Collection<array-key, Product> */
#[ORM\OneToMany(targetEntity: Product::class, mappedBy: 'vendor')]
private Collection $products;
// ProductType.php
->add('vendor', EntityType::class, [
'label' => 'Vendor',
'required' => false,
'class' => Vendor::class,
'choice_label' => static fn(Vendor $d) => $d->getName() . ' (' . $d->getCode() . ')',
])
Possible Solution
No response
Additional Context
Native lazy objects enabled: