Forums › Forums › OroPlatform › Custom Error Messages in the Flash Message
This topic contains 7 replies, has 3 voices, and was last updated by zhex900 6 years, 8 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- July 31, 2017 at 12:58 am #37046
Hi,
How do I create a customer error message? I want it to stop the application and display the error message in the flash message.Jake He
- CreatorTopic
- AuthorReplies
- July 31, 2017 at 11:44 am #37047
Hi, Jake!
Actually, it depends on where do you want to create an error message. You have following options, for example:
1) You, of course, always have a regular Symfony-based ability to throw flash messages from Session. In controllers, particularly, you can use addFlash() method for this (please, see the Symfony’s “Controller” documentation article)
2) In Oro Workflows (and processes) you can use “@flash_message” action:
YAML123- @flash_message:message: "Your message here!"type: 'error'For detailed examples, please, look for “@flash_message” usages in workflow definitions in Oro bundles.
Regards!
July 31, 2017 at 11:51 pm #37048Hi,
Thank you for your reply.
I want to throw an error message in a custom class I had. This is what I done.
1) Inject session into my class
2) $this->session->getFlashBag()->add(‘error’, ‘Calendar does not exist.’);However this error message is not displayed.
Jake He
August 1, 2017 at 12:02 am #37049August 1, 2017 at 2:55 am #37050Hi, @zhex900. Very strange that you does not see your message from the $this->session->getFlashBag()->add(‘error’, ‘Calendar does not exist.’);. I gust tested your case and all works for me.
Please see, maybe you have some JS error.
About the message from the exception. As for me it is not very good idea to send error messages as flash message because user should have translated message that will describe what was going wrong.
August 1, 2017 at 3:15 am #37051Error: Unexpected content format flash message displayed first. After I go another page like contacts. Calendar does not exist flash message comes up.
I want to stop the app and display an error message. Like validation.
August 3, 2017 at 5:16 am #37052Hi,
I know what the problem is. The session service I injected is null. But how do I fix it?
August 3, 2017 at 5:25 am #37053I found a work around. I throw an exception and catch it at the class that calls it.
- AuthorReplies
The forum ‘OroPlatform’ is closed to new topics and replies.