Repository navigation
Flash Message
Flash message component is designed to display messages to the user with customizable options. It can be used to show alerts or notifications on a web page.
First of all, we need to add the component Sy\Bootstrap\Component\FlashMessage in the web page:
$this->setVar('FLASH_MESSAGE', new \Sy\Bootstrap\Component\FlashMessage());This component embeds a javascript function that can be called to show a new message.
-
message: This can be either a string or a JSON object.- If it's a string, it represents the message you want to display.
- If it's a JSON object, it should have the following structure:
{ "title": "Your title here", "body": "Your message body here" } - The
titleandbodyare both strings that represent the header and the content of the message, respectively.
-
color(optional): A string that specifies the color of the alert message. This should be a valid Bootstrap alert color value (e.g.,primary,secondary,success,danger,warning,info,light,dark). Default value issuccess. -
autohide(optional): A boolean value that determines whether the message should automatically disappear after a certain period or if it requires manual dismissal by the user. Default value istrue.-
true: The message will auto-hide. -
false: The message will stay visible until the user dismisses it manually.
-
flash({ title: 'Success!', body: 'Your operation was completed.' }, 'info', false);