src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php
public function setFlashMessage(Form $form, $message, SessionInterface $session = null)
    {
        if (null === $session) {
            trigger_error(
                "Please do not rely on the container's instance of the session, but fetch it from the Request",
                E_USER_DEPRECATED
            );
            $session = $this->session;
        }
        $session->getFlashBag()->set($this->getFormId($form), $message);
    }
public function setFlashMessage(Form $form, $message, SessionInterface $session = null)
    {
        if (null === $session) {
            trigger_error(
                "Please do not rely on the container's instance of the session, but fetch it from the Request",
                E_USER_DEPRECATED
            );
            $session = $this->session;
        }
        $session->getFlashBag()->set($this->getFormId($form), $message);
    }
public function setFlashMessage ( Form $ form , $ message , SessionInterface $ session = null ) { if ( null === $ session ) { trigger_error ( "Please do not rely on the container's instance of the session, but fetch it from the Request" , E_USER_DEPRECATED ) ; $ session = $ this -> session ; } $ session -> getFlashBag ( ) -> set ( $ this -> getFormId ( $ form ) , $ message ) ; }
A generic way to set flash messages.

When using this make sure you set the following parameter in your parameters.yml to avoid stacking of messages
when they are not shown or rendered in templates

session.flashbag.class: Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag

Messages will be pushed to a viewVars called 'messages' see $this->handleForm

@param Form $form
@param string $message
A generic way to set flash messages .