Last active
September 30, 2016 15:21
-
-
Save treetop1500/e2acf684001a41eceb74c0f34818240a to your computer and use it in GitHub Desktop.
Flash Message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controller delete action: | |
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; | |
... | |
try { | |
$em->remove($entity); | |
$em->flush(); | |
} catch(ForeignKeyConstraintViolationException $e) { | |
$this->addFlash('warning', 'This item is in use by related entities and cannot be deleted.'); | |
} | |
// twig (Foundation 5): | |
{% for flash_message in app.session.flashBag.get('warning') %} | |
<div data-alert class="alert-box warning"> | |
{{ flash_message|raw }} | |
<a href="#" class="close">×</a> | |
</div> | |
{% endfor %} | |
// twig (Foundation 6): | |
{% for flash_message in app.session.flashBag.get('warning') %} | |
<div class="callout warning" data-closable> | |
{{ flash_message|raw }} | |
<button class="close-button" aria-label="Dismiss alert" type="button" data-close> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment