Nested runAction


(Ric128) #1

I have the following problem.
My app runs a runAction A that then runs a runAction B. Both actions are within the same controller.
In runAction B I notice very strange behaviors that I cannot understand (for example, the actions taken by the user in runAction B do nothing and always send me to runAction A).
The logic works correctly when I use Redirect instead of runAction. The reason I use runAction and not Redirect is that actions must be called with the POST method that is not supported by Redirect.
Does anybody have any suggestions.
Thank you.


#2

Hi,
can you post some code?


(Ric128) #3
<?php

namespace backend\controllers;

class DemoController extends Controller
{
public function behaviors()
{
return [
‘verbs’ => [
‘class’ => VerbFilter::className(),
‘actions’ => [
‘first’ => [‘post’],
‘second’ => [‘post’],
],
],
];
}

public function actionIndex()
{
    .
    .
    Yii::$app->runAction('demo/first/');
    .
    .
}

public function actionFirst()
{
    .
    .
    Yii::$app->runAction('demo/second/');
    .
    .
}

public function actionSecond()
{
    .
    .
}

}


#4

Why don’t use a simple Ajax post request ?


(Ric128) #5

Thx hyde82
I’am just experimenting.