From c5506285586414c86cd2a25dfbd7579eb952fba8 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Wed, 20 Nov 2013 22:35:35 +0530 Subject: [PATCH] CSS Class assignment correction # 2. Ensure previous CSS classes are not appended and reinitialized in the foreach loop. --- apps/advanced/frontend/widgets/Alert.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/advanced/frontend/widgets/Alert.php b/apps/advanced/frontend/widgets/Alert.php index 29b2e5a..dc0cc30 100644 --- a/apps/advanced/frontend/widgets/Alert.php +++ b/apps/advanced/frontend/widgets/Alert.php @@ -41,10 +41,11 @@ class Alert extends Widget $this->_doNotRender = true; $session = \Yii::$app->getSession(); $flashes = $session->getAllFlashes(); + $baseCssClass = isset($this->options['class']) ? $this->options['class'] : ''; + foreach ($flashes as $type => $message) { if (in_array($type, $this->allowedTypes)) { - $class = ($type === 'error') ? 'alert-danger' : 'alert-' . $type; - Html::addCssClass($this->options, $class); + $this->options['class'] = (($type === 'error') ? "alert-danger" : "alert-{$type}") . ' ' . $baseCssClass; echo BsAlert::widget([ 'body' => $message, 'closeButton' => $this->closeButton,