Victor Bocharsky
Victor Bocharsky

Reputation: 12306

How to set array value in twig template

How I can change my array value by string index in twig template? I'm trying:

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

but I get nex error:

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

I also trying:

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

but have error too:

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

Any ideas?

Upvotes: 4

Views: 11498

Answers (1)

Ahmed Siouani
Ahmed Siouani

Reputation: 13891

what about,

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

Upvotes: 6

Related Questions