|
|
@ -24,9 +24,18 @@ use yii\bootstrap\Alert as BsAlert; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class Alert extends Widget |
|
|
|
class Alert extends Widget |
|
|
|
{ |
|
|
|
{ |
|
|
|
private $_doNotRender = true; |
|
|
|
/** |
|
|
|
|
|
|
|
* @var array the allowed bootstrap alert types. |
|
|
|
|
|
|
|
*/ |
|
|
|
public $allowedTypes = ['error', 'danger', 'success', 'info', 'warning']; |
|
|
|
public $allowedTypes = ['error', 'danger', 'success', 'info', 'warning']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @var array the options for rendering the close button tag. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public $closeButton = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private $_doNotRender = true; |
|
|
|
|
|
|
|
|
|
|
|
public function init() |
|
|
|
public function init() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_doNotRender = true; |
|
|
|
$this->_doNotRender = true; |
|
|
@ -35,9 +44,10 @@ class Alert extends Widget |
|
|
|
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; |
|
|
|
$class = ($type === 'error') ? 'alert-danger' : 'alert-' . $type; |
|
|
|
Html::addCssClass($this->options, $class); |
|
|
|
$this->options['class'] = $class; |
|
|
|
echo BsAlert::widget([ |
|
|
|
echo BsAlert::widget([ |
|
|
|
'body' => $message, |
|
|
|
'body' => $message, |
|
|
|
|
|
|
|
'closeButton' => $this->closeButton, |
|
|
|
'options' => $this->options |
|
|
|
'options' => $this->options |
|
|
|
]); |
|
|
|
]); |
|
|
|
$session->removeFlash($type); |
|
|
|
$session->removeFlash($type); |
|
|
|