Flash-Message Service & error-block =================================== The Flash-Builder writes a message to the Session, which can be displayed exactly once by the user. This service (``flash_msg``) is a short version for ``$this->container->get('session')->getFlashBag()`` which helps to format the message. .. code-block::php $this->get('flash_msg')->set($message, $type=“notice“, $translation=’’); There are some different possibilities to set the Flash-Message with the translation: + **use the default translations** (recommended only for already translated text, "notice" is the default tag, which is used as html-class to display) .. code-block:: php $this->container->get('flash_msg')->set('Message-Text'); + **the message-type is 'danger'** .. code-block:: php $this->container->get('flash_msg')->set('Message-Text', 'danger'); + **the string 'translation_domain' is used** as Translation-Domain to translate the "Message-Text"-String. .. code-block:: php $this->container->get('flash_msg')->set('Message-Text', 'info', 'translation_domain'); + The the **first Array** (%replace%-Key) tells the Translator to replace the %replace%-string with the given "Text". In the "translation_domain"-Translation-Messages, the string "Message-Text-Replace" is translated as ``the Text is replaced -> Text``. .. code-block:: php $this->container->get('flash_msg')->set('Message-Text-Replace', 'danger', array(['%replace%' => 'Text'], 'translation_domain')); .. code-block:: yaml # translation_domain.en.yml Message-Text-Replace: "the Text is replaced -> %replace%" **Bootstrap 3** supports the `alert-classes `_ ("success", "info", "warning", "danger"). This are the possible ``$type``-vars, which are inserted directly into the div-class (``
``) .. note:: The Flash-Message is displayed automatically in the twig-templage ``layout.html.twig`` (tpointCoreBundle). The Flash-Block (``{% block flashBlock %}``) is located inside the ``{% block content %}`` but outside the ``{% block body %}``. This means, that the Flash-Message would not be displayed, if there is some "full-size-contents" (Twig-Template uses the ``content``-Block (all Page Contents) or the ``mainContent``-Block (anything after the Navbar) to display the Content). Error-Messages """""""""""""" The var ``$errors`` (must be an array) can be added to the ``render()``-method in the controller. Each array-element is rendered as new ``

`` in the alert-div. .. code-block:: html

{% for error in errors %}

{{ error }}

{% endfor %}
.. note:: As you can see, the messages are not translated. You have to pass the translated strings to the error-array.