In view I have widget:
if ($content):
echo Alert::widget([
'options' => [
'class' => 'alert-info',
],
'body' => $content,
]);
endif;
That widget I want render not always, for example after save and atc. Now Now I have placed that widget between if condition, maybe exists some more clear way to render widget only in some cases.
I think Flash-Messages is what you want:
For Example:
In the controller you can do something like that:
And in the view:
And of course you can combine it with the alert-widget or with a custom-widget.
See full documentation: http://www.yiiframework.com/wiki/21/how-to-work-with-flash-messages/