title: Symfony use Form Event to change data before it submits
body: <p>I have the Form Event <code>FormEvents::PRE_SUBMIT</code> in place</p>
  
  <pre><code>namespace AppBundle\Form\EventListener;
  
  use Doctrine\ORM\EntityManager;
  use Symfony\Component\Form\FormEvent;
  use Symfony\Component\Form\FormEvents;
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
  
  
  class AddProfileFieldSubscriber implements EventSubscriberInterface
  {
      protected $authorizationChecker;
  
      protected $em;
  
      function __construct(AuthorizationChecker $authorizationChecker, EntityManager $em)
      {
          $this-&gt;authorizationChecker = $authorizationChecker;
          $this-&gt;em = $em;
      }
  
      public static function getSubscribedEvents()
      {
          // Tells the dispatcher that you want to listen on the form.pre_set_data
          // event and that the preSetData method should be called.
          return array(
              FormEvents::PRE_SUBMIT =&gt; 'onPreSubmit'
          );
      }
  
  
      /**
       * @param FormEvent $event
       */
      public function onPreSubmit(FormEvent $event){
  
          $interestTags = $event-&gt;getData();
          $interestTags = $interestTags['interest'];
          foreach($interestTags as $key =&gt; $interestTag){
                  $interestTags[$key] = "55";
              }
          }
  }
  </code></pre>
  
  <p>Inside the function <code>onPreSubmit</code> if i dump the <code>$event</code> I can see the following information.</p>
  
  <p><a href="https://i.stack.imgur.com/fTIpe.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fTIpe.jpg" alt="enter image description here"></a></p>
  
  <p>All I want to do is change the <code>value</code> of <code>key</code> where you see the red arrow being pointed, so that moving on the rest of the process takes the new <code>value</code> rather than the old one.</p>
  
  <p>The approach i used seems to change the value alright but as soon as i move out of the foreach loop the old value remains, what do I need to do so that <code>qqq</code> is replaced by for example <code>444</code> for rest of the process?</p>