I'm creating a form using the form builder in Symfony. I am adding an attribute into the twig file for my checkboxes which contains an ampersand and pound sign, Symfony is automatically escaping the ampersand which stops it displaying correctly. Is there anyway to turn off escaping on a per case basis in either the twig file or the controller, or switch it off completely in the config?
{{ form_widget(form.checkbox, { 'attr': {'data-icon-checkmark': '󰀦', 'data-icon-checkmark-checked': '󰀧'} }) }}
I have found a few topics on this for 1.X versions of Symfony, but nothing for 2.
Thanks!
You can use |raw filter. http://symfony.com/doc/current/book/templating.html#output-escaping-in-twig
Probably what you need is the
raw
tag or filter. Also take a look at theautoescape
tag.To turn autoescaping off globally, set the
autoescape
option tofalse
inconfig.yml
: