I'm using Symfony 3.4 and I have a weird thing todo, I will try to explain clearly.
I have an Entity Website
and a WebsiteFormType
, in this WebsiteFormType
I have a Listener like : (in the first line of buildForm()
in formType)
$builder->addEventSubscriber(new WebsiteListener();
In this listener, I need to check when a specific value is updated when the form is submited, and if this value is updated, I need to duplicate my object, for example when I update my Website and I change the url
from http://xxx.xx
to http://yyyy.yy
I duplicate my first website to create the second instead of just update the field url
.
In this Listener I use preSubmit
and postSubmit
.
My problem is, when I change the url I need to change the object Website linked to the form.
If http://xxx.xx
is WebsiteA and http://yyyy.yy
is WebsiteB, When I submit WebsiteA and I change the url, I need to change the Website object linked to the form from WebsiteA to WebsiteB....
This is for if I revalidate the form after that, it's WebsiteB which is validated and not WebsiteA.
Don't know if you understand my problem :) Thanks !