How to have twig path() with silex slug?

时间:2017-11-08 22:08:10

标签: php symfony twig silex

In silex I have something like

$controllers->get('/{id}', 'Controllers\\Login::index')->bind('login');

when in twig I try to get path('login') I get exception

("Some mandatory parameters are missing ("id") to generate a URL for route "login"."). ?

I know this is because of {id} and I have to pass a second parameter to path() but how should it look like?

1 个答案:

答案 0 :(得分:1)

要将参数传递给twig路径,请使用以下语法:

{{ path('login', {'id': 'your-id-here'}) }}

您可以在这里查看文档:

Path() function documentation, symfony

您可以按照此处的说明传递几个参数:

SO: several paremeters in twig