Data don’t persist from modal – Symfony 4

  bootstrap-modal, forms, persist, symfony

Hello everybody !
I’m a beginner at dev and Symfony.

I want to display a form in a Bootstrap modal, which works perfectly, but it doesn’t persist in database when I submit it. (This form worked perfectly, persist and eveything, before I put it on a modal)

I found some ressources to help, but it’s never the same problem than mine

If anyone could help me, it would be so perfect !
Thank you =)

This is my controller :

public function new(Request $request): Response
        $favorite = new Favorite();
        $newFavoriteForm = $this->createForm(NewFavoriteType::class, $favorite);

        if ($newFavoriteForm->isSubmitted() && $newFavoriteForm->isValid()) {
            $entityManager = $this->getDoctrine()->getManager();

            return $this->redirectToRoute('/');

        return $this->render('/tcheen/profile_customer/new_favorite.html.twig', [
            'favorite' => $favorite,
            'new_favorite_form' => $newFavoriteForm->createView(),

This is my Twig :

<div class="modal fade" id="new-favorite-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLongTitle">Nouveau favori</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
            <div class="modal-body">
                <h2> Créer un nouveau favori</h2>
               {{ form_start(new_favorite_form) }}
                {{ form_widget(new_favorite_form) }}
                <button class="btn btn-success">{{ button_label|default('Ajouter') }}</button>
                {{ form_end(new_favorite_form) }}


And the view where it is display :

                Pas encore de favoris ?
                <a href="{{ path('favorite_new') }}" data-toggle="modal" data-target="#new-favorite-modal">
                    <button type="button" class="btn main-button">
                        Créer un favori
                {{ render(controller('AppControllerFavoriteController::new')) }}
                {#{{ include ('tcheen/profile_customer/new_favorite.html.twig') }}#}


Source: Symfony Questions