-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Twig Trying to Render Json Model #83
Comments
It's trying to render it only if model's template exists, which seems logical to me. |
How to prevent it? I would like to have one action for twig and json respond. How could I do that? |
This is just internal to how ZF2 works. If you return a JsonModel then the JsonViewStrategy is used. If you return a ViewModel then the default Twig/PhpRendererStrategy is used. You need to have your strategies registered in the right order. JsonViewStrategy should be set in 'view_manager' => 'strategies' earlier than Twig is loaded. |
I'm not sure. Try ie. https://github.com/zendframework/ZendSkeletonApplication, install it, but in |
I was also affected by this and in my case changing the order of the modules broke my app. To get around this I registered a ModuleEvent listener that prioritises Here's a gist for it. |
Hi,
I have just came across an issue where the twig strategy is trying to render a Json Model even though this should be possible.
The fix should be as follows: ZfcTwig\View\TwigStrategy::selectRenderer
This function should have the following before you run the can render function.
Many Thanks,
Tom
The text was updated successfully, but these errors were encountered: