如何在Twig模板中通过字符串索引更改数组值?我尝试着:

{% do params['redirect_uri'] = 'http://site.loc/' %}


但我得到nex错误:

Unexpected token "operator" of value "=" ("end of statement block" expected) in
BWUserBundle:User/social:sign-in-thumbs.html.twig at line 4


我也尝试:

{% set params['redirect_uri'] = 'http://site.loc/' %}


但也有错误:

Unexpected token "punctuation" of value "[" ("end of statement block" expected) in
BWUserBundle:User/social:sign-in-thumbs.html.twig at line 4


有任何想法吗?

最佳答案

关于什么,

{% set params = params|merge({'redirect_uri': 'http://site.loc/'}) %}

07-24 18:27
查看更多