当前位置: 动力学知识库 > 问答 > 编程问答 >

redirect - Symfony2 - By default default route parameter is set, work but is not displayed

问题描述:

I set a defaults value for my route so the route has a default value and my action works fine but the default value is not displayed in the URL. I try to redirect to the root like below :

if ($value == "TheValueRequired")

{

return $this->redirect($this->generateUrl("the_right_route", array(

'value' => $value,

)));

}

It works but then I loose the array that contains the variables for the rendering of the twig template.

网友答案:

A small example of what you could have in your controller if your goal is to display value in the view:

/.../

if ($value == "TheValueRequired") {

    return $this->render('template.html.twig', ['value' => $value]);

}

/.../
分享给朋友:
您可能感兴趣的文章:
随机阅读: