2014-01-14 29 views
3

如何通过树枝模板中的字符串索引更改数组值?我想:如何在树枝模板中设置数组值

{% 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 

任何想法?

回答

5

怎么样,

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

'意外标记的值 “标点”。 “” (预计结束语句块)BWUserBundle:User/social:sign-in-thumbs.html.twig at line 4' –

+0

好的,现在检查更新。 –

+0

很酷,它的工作!谢谢! :) –