Commit efe3bb3b authored by Mat's avatar Mat

on utilise les flashes avec les forms classiques, juste après le flush

* en ajax/API c'est souvent pas nécessaire
* ici l'affichage twig, nouvelle manière
parent 0821f14f
...@@ -31,6 +31,7 @@ class ImageController extends MasterController ...@@ -31,6 +31,7 @@ class ImageController extends MasterController
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist($image); $em->persist($image);
$em->flush(); $em->flush();
$this->addFlash('success', 'Votre image a bien été sauvegardée.');
return $this->redirectToRoute('techno_gallery_read'); return $this->redirectToRoute('techno_gallery_read');
} }
......
...@@ -11,14 +11,13 @@ ...@@ -11,14 +11,13 @@
<h1>{{ block('title') }}</h1> <h1>{{ block('title') }}</h1>
<a href="{{ path('techno_gallery_read') }}"><i class="fas fa-arrow-left fa-fw"></i>Retour vers la liste</a> <a href="{{ path('techno_gallery_read') }}"><i class="fas fa-arrow-left fa-fw"></i>Retour vers la liste</a>
<ul> {% for label, messages in app.flashes({'success', 'warning', 'errors'}) %}
{% for flashMessage in app.session.flashbag.get('mardi') %} {% for message in messages %}
<li> <div class="flash-{{ label }}">
{{ flashMessage }} {{ message }}
</li> </div>
{% endfor %}
{% endfor %} {% endfor %}
</ul>
{{ form_start(formImage) }} {{ form_start(formImage) }}
{{ form_errors(formImage) }} {{ form_errors(formImage) }}
...@@ -28,7 +27,7 @@ ...@@ -28,7 +27,7 @@
{{ form_row(formImage.legend) }} {{ form_row(formImage.legend) }}
{{ form_row(formImage.owner) }} {{ form_row(formImage.owner) }}
{{ form_row(formImage.save) }} {{ form_row(formImage.save) }}
{{ form_end(formImage) }} {{ form_end(formImage) }}
{% endblock %} {% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment