简体   繁体   中英

Symfony3: in Twig, pass Request with Render function

this question was asked for Symfony 2 as well and answered. Link

the problem now is that there is no {% render %} Tag in Symfony 3.

    {{ render(url('simpleSearch'), {'originalRequest' : app.request}) }}

this is my try. it render a form in the action and this should show at a position in all actions. the form works and also the rendering, but the form got no request informations cause in the deep of the render() function there is this code

$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);

this create a blank request and pass it to the rendering action.

Did someone know how i can get the original request like in symfony 2?

Ok, i got a solution,

you cant get the information to the render function BUT to the url function.

it should look like this

{{ render(url('simpleSearch', app.request.query.all)) }}

the url funtion only allows an array so .all is a possible solution to get the information in the sub action

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM