我从一个 Action (executeProcess)重定向到另一个(executeIndex)。我希望能够不使用GET传递参数/变量(例如$this->redirect('index', array('example'=>'true'))
)
有没有一种方法可以直接传递参数而无需直接在URL中显示? (例如POST)。谢谢。
最佳答案
为什么不在重定向之前使用 session 来存储值,然后在重定向后又将其用于其他操作?喜欢:
class ActionClass1 extendes sfActions
{
public function executeAction1(sfWebRequest $request)
{
[..]//Do Some stuff
$this->getUser()->setAttribute('var',$variable1);
$this->redirect('another_module/action2');
}
}
class ActionClass2 extends sfActions
{
public function executeAction2(sfWebRequest $request)
{
$this->other_action_var = $this->getUser()->getAttribute('var');
//Now we need to remove it so this dont create any inconsistence
//regarding user navigation
$this->getUser()->getAttributeHolder()->remove('var');
[...]//Do some stuff
}
}
关于parameter-passing - Symfony : pass parameter between actions (with a redirect),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5229494/