I'm trying to insert a data passed in the form (e-mail) in the response that I create in the listener to ensure that the response is a json object.
I can not take the form data from 'event in any way ..
There is a solution to what I want?
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::PROFILE_EDIT_SUCCESS => 'onProfileEditSuccess',
);
}
public function onProfileEditSuccess(FormEvent $event)
{
$response = new Response();
$output = array('success' => true, 'new_mail' => $event); //event return empty object
$response->headers->set('Content-Type', 'application/json');
$response->setContent(json_encode($output));
$event->setResponse($response);
}
I tried to listen to the event COMPLETED, but does not make me change response!