Good day to all,
i’m a newby with Yii framework and PHP.
I call a SQL Stored Procedure with a button; query caller in is controller, while button is in the form; when action is terminated, calling setFlash, i show a message for the user; i would like to show a message also before the action start, or immediately after, something like “Waiting action…”, but i can not.
I try to use beforeAction() or afterAction(), but only “Action done” message appears when action is terminated; i try also with setFlash() and hasFlash(), but the message appears only when action is terminated, two messages in this case, “Waiting” and “Done”.
There is a way to intercept the button pressed in the form and show message “Waiting” ?
Thanks
I try to change button with submitButton and call function in controller, but i have the same result.
What is the best way to show setFlash with waiting message, starting function and then show setFlash with result message ?
Thanks
I have tried some solutions, but it don’t works; i have tried with another view, popup, some js code, but the problem remains: when controller action begin its job, the view don’t update itself, only when the action is terminated.
The last code on controller:
public function actionBeforedbmaintenance($dbaction)
{
Yii::$app->session['dbAction'] = $dbaction;
Yii::$app->session['isWaiting'] = true;
Yii::$app->session->setFlash('WaitFileStat');
return $this->redirect(Yii::$app->request->referrer);
}
public function actionDbmaintenance($dbaction)
{
Yii::$app->session['isWaiting'] = false;
Yii::$app->session['dbAction'] = 'none';
Yii::$app->session->removeFlash('WaitFileStat');
switch ($dbaction)
{
case "FileStatDB":
$this->Test('DB');
break;
case "FileStatLOG":
$this->Test('DB');
break;
}
}
public function Test($type)
{
for ($mul = 1; $mul <= 100000000; ++$mul);
Yii::$app->session->setFlash('success', Yii::t('app', 'Test done.'));
return $this->redirect(Yii::$app->request->referrer);
}
I also try to use “target = _blank”, but after i have one more tab opened on browser.
I don’t like that the user press one of the buttons, backup or reindex on database begin, and the view remains without warning to wait the end of operation.
At the moment i have no more idea.
Can anyone help me ?