public function init() { parent::init(); $session = \Yii::$app->session; $flashes = $session->getAllFlashes(); $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : ''; foreach ($flashes as $type => $data) { //TOAST if (strpos($type, 'toast') !== false) { if (isset($this->toastTypes[$type])) { $data = (array) $data; foreach ($data as $i => $message) { /* initialize css class for each alert box */ $tipo = $this->toastTypes[$type]; Toast::widget(['tipo' => $tipo, 'mensaje' => $message]); } $session->removeFlash($type); } } else { if (isset($this->alertTypes[$type])) { $data = (array) $data; foreach ($data as $i => $message) { //echo '<pre>';print_r($i);die(); /* initialize css class for each alert box */ $this->options['class'] = $this->alertTypes[$type] . $appendCss; /* assign unique id to each alert box */ $this->options['id'] = $this->getId() . '-' . $type . '-' . $i; echo \yii\bootstrap\Alert::widget(['body' => $message, 'closeButton' => $this->closeButton, 'options' => $this->options]); } $session->removeFlash($type); } } } }