Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[Edit form] User is persisted even with invalid data #2822
Hello FOS community,
I face something strange with the UserBundle. Here are the details:
I created a new SF2.8 project and installed FOSUserBundle following the official documentation.
Moreover, I added an event subscriber doing an
The validation fails and an error message is displayed "Please enter a username." as expected.
SELECT * FROM user
If I disable my event subscriber responsible of the
Do I misunderstand something ?
Well, if you have an event listener forcing a flush, you are creating the bug. As soon as an object is known by Doctrine, changes in it will be saved on flush. And during edition, the object being edited is already known by Doctrine, as it was loaded from the DB.
If you want to always do flushes automatically in a listener and avoid getting issues for invalid objects, you would need to use the explicit change tracking feature of Doctrine (which would consider changes only for objects on which
I'm closing this issue, because the bug is not in FOSUserBundle, but in the way you use Doctrine in your project.
Thank you for your reply.
I believed FOSUserBundle did not call
Indeed, it's my way of use of Doctrine that creates the bug.