Add more than one parameter in Twig path

后端 未结 2 936
悲&欢浪女
悲&欢浪女 2021-01-30 11:53

How to add more than one parameter in Twig path?
Say you have this route :

article_show:
    pattern:  /article/{slug}
    defaults: { _controller: AcmeArtic         


        
相关标签:
2条回答
  • 2021-01-30 12:45

    You can pass as many arguments as you want, separating them by commas:

    {{ path('_files_manage', {project: project.id, user: user.id}) }}
    
    0 讨论(0)
  • 2021-01-30 12:58

    Consider making your route:

    _files_manage:
        pattern: /files/management/{project}/{user}
        defaults: { _controller: AcmeTestBundle:File:manage }
    

    since they are required fields. It will make your url's prettier, and be a bit easier to manage.

    Your Controller would then look like

     public function projectAction($project, $user)
    
    0 讨论(0)
提交回复
热议问题