且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 Symfony2 加载控制器功能并将其呈现在 twig 标签中?

更新时间:2023-11-17 12:44:34

如果您有动态数据,您可以使用 ajax,但据我所知,从您的简要信息中可以看出,您始终可以直接从您的视图中执行该控制器功能:

You can use ajax if you have dynamic data, but as far as I can see from your brief info, you can always execute that controller function directly from your view:

{% render "MyMyBundle:User:generateCode" with { 'url': 'your url here' } %}

更多信息请访问:http://symfony.com/doc/2.0/quick_tour/the_view.html, 在嵌入其他控制器下

More Information on this available at: http://symfony.com/doc/2.0/quick_tour/the_view.html, under Embedding other Controllers