Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
cca34951
Commit
cca34951
authored
Jun 20, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3979: Alert widget in advanced app is now able to display multiple flash…
Fixes #3979: Alert widget in advanced app is now able to display multiple flash messages of the same type
parent
b12f4dd7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
Alert.php
apps/advanced/frontend/widgets/Alert.php
+15
-4
No files found.
apps/advanced/frontend/widgets/Alert.php
View file @
cca34951
...
...
@@ -11,9 +11,17 @@ namespace frontend\widgets;
* Alert widget renders a message from session flash. All flash messages are displayed
* in the sequence they were assigned using setFlash. You can set message as following:
*
* - \Yii::$app->getSession()->setFlash('error', 'This is the message');
* - \Yii::$app->getSession()->setFlash('success', 'This is the message');
* - \Yii::$app->getSession()->setFlash('info', 'This is the message');
* ```php
* \Yii::$app->getSession()->setFlash('error', 'This is the message');
* \Yii::$app->getSession()->setFlash('success', 'This is the message');
* \Yii::$app->getSession()->setFlash('info', 'This is the message');
* ```
*
* Multiple messages could be set as follows:
*
* ```php
* \Yii::$app->getSession()->setFlash('error', ['Error 1', 'Error 2']);
* ```
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @author Alexander Makarov <sam@rmcreative.ru>
...
...
@@ -47,8 +55,10 @@ class Alert extends \yii\bootstrap\Widget
$flashes
=
$session
->
getAllFlashes
();
$appendCss
=
isset
(
$this
->
options
[
'class'
])
?
' '
.
$this
->
options
[
'class'
]
:
''
;
foreach
(
$flashes
as
$type
=>
$
message
)
{
foreach
(
$flashes
as
$type
=>
$
data
)
{
if
(
isset
(
$this
->
alertTypes
[
$type
]))
{
$data
=
(
array
)
$data
;
foreach
(
$data
as
$message
)
{
/* initialize css class for each alert box */
$this
->
options
[
'class'
]
=
$this
->
alertTypes
[
$type
]
.
$appendCss
;
...
...
@@ -60,6 +70,7 @@ class Alert extends \yii\bootstrap\Widget
'closeButton'
=>
$this
->
closeButton
,
'options'
=>
$this
->
options
,
]);
}
$session
->
removeFlash
(
$type
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment