Well, I don’t know what to do to fix a bug in my project.
I’m trying to handle a nested form with a many-to-many-with-attribute relationship.
The errors says it cannot create the association because an ID is required for one of the side.
Alright. So I tried to create just the missing side.
But still the same error.
Finally, I realized that I had still the same problem with this simple code :
public function onSuccess(Page $page)
{
$this->em->flush();
}
I would appreciate to have an error message such as “hey, there’s nothing to flush!”
But no, still the same error : I have to create the object (and its id) prior to associate it.
I had a look to the stack trace. And yes, it seems that UnitOfWork ->computeAssociationChanges is called after the flush, and requires Ids for associated objects.
How can I create the objects in the database if the flush command generates a bug ?
Problem was due to a maj misspell in an entity class.
I found it by checking the schema structure, using an add-on to Symfony:
Source: Ulrich
This allowed to use this command instruction to detect the entity misspell.