Hello!!
I want first in a submit form , first to display one flash message , when is a success , and then redirect.
Currently, It redirects , but it does not displaying the flash message.
How ,to first display the flash message and then to redirect?
In the controller:
if ($order->validate()) {
$order->save();
Yii::$app->session->setFlash('success', "Order is made!!");
return $this->redirect('index');
} else {
die(var_dump($order->errors, true));
}
In the view:
<?php if (Yii::$app->session->hasFlash('success')): ?>
<div class="alert alert-success alert-dismissable">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
<?= Yii::$app->session->getFlash('success') ?>
</div>
<?php endif; ?>
ANy help is much appreciated!