Commit c5506285 by Kartik Visweswaran

CSS Class assignment correction # 2.

Ensure previous CSS classes are not appended and reinitialized in the foreach loop.
parent affa9589
...@@ -41,10 +41,11 @@ class Alert extends Widget ...@@ -41,10 +41,11 @@ class Alert extends Widget
$this->_doNotRender = true; $this->_doNotRender = true;
$session = \Yii::$app->getSession(); $session = \Yii::$app->getSession();
$flashes = $session->getAllFlashes(); $flashes = $session->getAllFlashes();
$baseCssClass = isset($this->options['class']) ? $this->options['class'] : '';
foreach ($flashes as $type => $message) { foreach ($flashes as $type => $message) {
if (in_array($type, $this->allowedTypes)) { if (in_array($type, $this->allowedTypes)) {
$class = ($type === 'error') ? 'alert-danger' : 'alert-' . $type; $this->options['class'] = (($type === 'error') ? "alert-danger" : "alert-{$type}") . ' ' . $baseCssClass;
Html::addCssClass($this->options, $class);
echo BsAlert::widget([ echo BsAlert::widget([
'body' => $message, 'body' => $message,
'closeButton' => $this->closeButton, 'closeButton' => $this->closeButton,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment