Browse Source

Permalien en complet + retour au show après modifs

Sangfroid 2 months ago
parent
commit
3156fc642c

+ 2 - 2
src/Controller/ArticleController.php

@@ -58,7 +58,7 @@ final class ArticleController extends AbstractController
             $entityManager->persist($article);
             $entityManager->flush();
 
-            return $this->redirectToRoute('app_view', ['slug' => $article->getSlug()], Response::HTTP_SEE_OTHER);
+            return $this->redirectToRoute('app_article_show', ['id' => $article->getId()], Response::HTTP_SEE_OTHER);
         }
 
         return $this->render('article/new.html.twig', [
@@ -106,7 +106,7 @@ final class ArticleController extends AbstractController
 
             $entityManager->flush();
 
-            return $this->redirectToRoute('app_view', ['slug' => $article->getSlug()], Response::HTTP_SEE_OTHER);
+            return $this->redirectToRoute('app_article_show', ['id' => $article->getId()], Response::HTTP_SEE_OTHER);
         }
 
         return $this->render('article/edit.html.twig', [

+ 1 - 1
templates/article/_form.html.twig

@@ -7,7 +7,7 @@
 
         {% set cacherFormulaire = article.slug and not article.slug is same as '' and form.children.slug.vars.errors|length == 0 %}
         <div data-slugger-target="ligneSlug" class="ligne-slug {{ cacherFormulaire ? '' : 'hidden' }}">
-            <div><span>Permalien</span> {{ article.slug }}</div>
+            <div><span>Permalien</span> {{ url('app_view', {slug: article.slug}) }}</div>
             <button type="button" class="bouton-slug" data-slugger-target="bouton-show" data-action="click->slugger#show">Modifier</button>
         </div>
         <div id="formulaire-slug" data-slugger-target="formulaire" class="{{ cacherFormulaire ? 'hidden' : ''}}">

+ 1 - 1
templates/article/show.html.twig

@@ -17,7 +17,7 @@
             </tr>
             <tr>
                 <th>Permalien</th>
-                <td>{{ article.slug }}</td>
+                <td>{{ url('app_view', {slug: article.slug}) }}</td>
             </tr>
             <tr>
                 <th>Date de publication</th>