Answer the question
In order to leave comments, you need to log in
How to render controller in twig template?
Today I upgraded to symfony 2.4 and ran into a code migration problem. Previously, this worked without problems. Now indexdata separately returns the desired results, but it is not possible to render it from the template of another controller
render(controller('BackendWorkorderBundle:Default:indexdata'))
LogicException: Rendering a fragment can only be done when handling a Request.
Answer the question
In order to leave comments, you need to log in
We need context. Where does the code run from, from a console command? Give an example of the method that you call .... In general, this error can only be from the fact that there is no Request object
Yes that's right. Understood. The call was from a twig template
{{ render(controller('BackendWorkorderBundle:Default:indexdata')) }} indexdata is the controller's action. The problem was the following.
I tried to get the $session in the action in the following way, which worked fine in 2.3.7
$request = $this->get('request');
$session = $request->getSession();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question