title: How to retrieve specific values in my form ? Symfony 6.0.2
body: <p>I try to define values in my search form, so that when user comes back to the form, he retrieves previous values he entered. I tried this, but it seems it's not the solution because I don't the results as expected.</p>
  <p>How can I retrieve values previously entered in my search form ?</p>
  <p>Thank you for your help.</p>
  <p><strong>search.html.twig</strong></p>
  <pre><code>{% extends 'base.html.twig' %}
  
  {% block title %}Liste des sorties et des activités !{% endblock %}
  
  {% block main %}
  
  {{ form_start(form) }}
      &lt;p&gt;Où souhaites-tu faire une sortie ou une activité ?&lt;/p&gt;
      {{ form_widget(form.bigcity, {'attr' : {'class' : 'mb-3'}, 'value' : app.session.get('bigcity.name')} ) }}
      &lt;p&gt;Quel type de sortie ou d’activité t’intéresse ?&lt;/p&gt;
      {{ form_widget(form.category, {'attr' : {'class' : 'mb-3'}, 'value' : app.session.get('category.title')} ) }}
      {{ form_widget(form.save, {'label': 'Je valide', 'attr' : {'class' : 'btn'}} ) }}
  {{ form_end(form) }}
  
  {% endblock %}
  </code></pre>
  <p><strong>SearchType.php</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Form;
  
  use App\Entity\BigCity;
  use App\Entity\Categories;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  
  class SearchType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options): void
      {
          $builder
              -&gt;add('bigcity', EntityType::class, [
                  'class' =&gt; BigCity::class,
                  'choice_label' =&gt; 'name',
                  'placeholder' =&gt; 'Sélectionne une grande ville',
              ])
              -&gt;add('category', EntityType::class, [
                  'class' =&gt; Categories::class,
                  'choice_label' =&gt; 'image',
                  'expanded' =&gt; true,
                  'multiple' =&gt; false,
              ])
              -&gt;add('save', SubmitType::class)
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver): void
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; null
          ]);
      }
  }
  </code></pre>
  <p><strong>EventsController.php</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Controller;
  
  use App\Form\SearchType;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\Routing\Annotation\Route;
  use Symfony\Component\HttpFoundation\Session\SessionInterface;
  use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  
  class EventsController extends AbstractController
  {   
      #[Route('/search', name: 'search')]
      public function search(Request $request, SessionInterface $sessionInterface)
      {   
          $data = $request-&gt;query-&gt;all();
          $sessionFormData  = $sessionInterface-&gt;get('data');
  
          $form = $this-&gt;createForm(SearchType::class, $data);
          $form-&gt;handleRequest($request);
          
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $data = $form-&gt;getData();
              $sessionInterface-&gt;set('data', $data);
              return $this-&gt;render('front/events.html.twig', $data);
          }
  
          return $this-&gt;renderForm('front/search.html.twig', [
              'form' =&gt; $form
          ]);
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/iVT5g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iVT5g.png" alt="enter image description here" /></a></p>