templates/flash_bag.html.twig line 1

Open in your IDE?
  1. {% set flashbagSuccess = app.session.flashbag.get('success') %}
  2. {% set flashbagError = app.session.flashbag.get('error') %}
  3. {% set flashbagInfo = app.session.flashbag.get('info') %}
  4. {% if flashbagSuccess is not empty or flashbagError is not empty or flashbagInfo is not empty %}
  5.     <script>
  6.         document.addEventListener('DOMContentLoaded', function () {
  7.             {% for message in flashbagSuccess %}
  8.             Swal.fire(
  9.                 'Opération réussie',
  10.                 "{{ message|trans }}",
  11.                 'success'
  12.             );
  13.             {% endfor %}
  14.             {% for message in flashbagError %}
  15.             Swal.fire(
  16.                 'Oops...',
  17.                 "{{ message|trans }}",
  18.                 'error'
  19.             );
  20.             {% endfor %}
  21.             {% for message in flashbagInfo %}
  22.             Swal.fire(
  23.                 'Info',
  24.                 "{{ message|trans }}",
  25.                 'error'
  26.             );
  27.             {% endfor %}
  28.         });
  29.     </script>
  30. {% endif %}