title: I need to keep user's data in form fields after redirection
body: <p>I'm writing simple carpark application for my assingment and one of the last things that I need to do is to keep user's data in form fields after it gets redirected. The redirection happens when spot that user wants to reserve is already taken.</p>
  
  <p>I found out that you can do it using session but I can't it doesn't work the way I want because I can't retrieve the data.</p>
  
  <p>Here's the method new in my Reservation Controller:</p>
  
  <pre class="lang-php prettyprint-override"><code>/**
       * New action.
       *
       * @param \Symfony\Component\HttpFoundation\Request $request    HTTP request
       * @param \App\Repository\ReservationRepository     $repository Reservation repository
       *
       * @return \Symfony\Component\HttpFoundation\Response HTTP response
       *
       * @throws \Doctrine\ORM\ORMException
       * @throws \Doctrine\ORM\OptimisticLockException
       *
       * @Route(
       *     "/new",
       *     methods={"GET", "POST"},
       *     name="reservation_new",
       * )
       */
      public function new(Request $request, ReservationRepository $repository): Response
      {
          $reservation = new Reservation();
          $form = $this-&gt;createForm(ReservationType::class, $reservation);
          $form-&gt;handleRequest($request);
  
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              if ($repository-&gt;findOneBy(['spot' =&gt; $reservation-&gt;getSpot()])) {
  
  //                $occupied_from = $form['occupied_from']-&gt;getData();
  //                $occupied_to = $form['occupied_to']-&gt;getData();
  //                $payment = $form['payment']-&gt;getData();
  //                $spot = $form['spot']-&gt;getData();
  
                  dump($request-&gt;request-&gt;get('reservation'));
  
  //                $occupied_from = $this-&gt;session-&gt;get('occupied_from', []);
  //                $occupied_to = $this-&gt;session-&gt;get('occupied_to', []);
  //                $payment = $this-&gt;session-&gt;get('payment', []);
  //                $spot = $this-&gt;session-&gt;get('spot', []);
  
  //                if ($reservation-&gt;getOccupiedFrom() == )
  
                  $this-&gt;addFlash('error', 'message.spot_taken');
  
                  return $this-&gt;redirectToRoute('reservation_new');
              }
  
              $reservation-&gt;setClient($this-&gt;getUser());
              $repository-&gt;save($reservation);
  
  
              $this-&gt;addFlash('success', 'message.updated_successfully');
  
              return $this-&gt;redirectToRoute('reservation_index');
  
          }
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid() &amp;&amp; $reservation-&gt;getOccupiedFrom() &lt; new \DateTime('now') ) {
  
              $this-&gt;addFlash('error', 'message.inconsistent_date');
  
          }
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid() &amp;&amp; $reservation-&gt;getOccupiedFrom() &gt; $reservation-&gt;getOccupiedTo()) {
  
              $this-&gt;addFlash('error', 'message.inconsistent_date');
  
              return $this-&gt;redirectToRoute('reservation_new');
          }
  
  
  
          return $this-&gt;render(
              'reservation/new.html.twig',
              ['form' =&gt; $form-&gt;createView()]
          );
      }
  
  </code></pre>
  
  <p>And here's the form for Reservation:</p>
  
  <pre class="lang-php prettyprint-override"><code> public function buildForm(FormBuilderInterface $builder, array $options): void
      {
          $builder-&gt;add(
              'occupiedFrom',
              DateTimeType::class,
              [
                  'widget' =&gt; 'choice',
                  'label' =&gt; 'label.occupied_from',
                  'placeholder' =&gt; [
                      'year' =&gt; 'Year', 'month' =&gt; 'Month', 'day' =&gt; 'Day',
                      'hour' =&gt; 'Hour', 'minute' =&gt; 'Minute', 'second' =&gt; 'Second',
                  ],
                  'data' =&gt; new\DateTime(),
                  'attr' =&gt; ['min' =&gt; (new DateTime())-&gt;format('YYYY-mm-dd HH:ii:ss')]
              ]
          );
  
          $builder-&gt;add(
              'occupiedTo',
              DateTimeType::class,
              [
                  'widget' =&gt; 'choice',
                  'label' =&gt; 'label.occupied_to',
                  'placeholder' =&gt; [
                      'year' =&gt; 'Year', 'month' =&gt; 'Month', 'day' =&gt; 'Day',
                      'hour' =&gt; 'Hour', 'minute' =&gt; 'Minute', 'second' =&gt; 'Second',
                  ],
                  'data' =&gt; new\DateTime(),
                  'attr' =&gt; ['min' =&gt; (new DateTime())-&gt;format('YYYY-mm-dd HH:ii:ss')]
              ]
          );
  
          $builder-&gt;add(
              'payment',
              EntityType::class,
              [
                  'class' =&gt; Payment::class,
                  'choice_label' =&gt; function ($payment) {
                      return $payment-&gt;getType();
                  },
                  'label' =&gt; 'label.payment',
                  'placeholder' =&gt; 'label.none',
                  'required' =&gt; true,
              ]
          );
  
          $builder-&gt;add(
              'spot',
              EntityType::class,
              [
                  'class' =&gt; Spot::class,
                  'choice_label' =&gt; function($spot) {
                  return $spot-&gt;getSpot();
                  },
                  'label' =&gt; 'label.spot',
                  'placeholder' =&gt; 'label.none',
                  'required' =&gt; true,
              ]
          );
  </code></pre>
  
  <p>There are 4 values I need to access: 'occupied_from' which is the starting date of the reservation, 'occupied_to' which is the ending date, 'payment' one of two ways of payment for the reservation and 'spot' which is the name of the spot.</p>
  
  <p>Whatever I do, I always get the redirect but data is not saved. Thanks in advance from an unexperienced collegue.</p>