Q:

Twig: use raw filter on form_widget attr

is it possible to use raw filter on form element attributes? I want something like:
{{ form_widget(searchForm.query, {
    'type': 'search',
    'attr': {
        'placeholder': 'Search query&hellip;'
    }
} ) }}

but this outputs "Search query&hellip;" into HTML
I've tried 
'placeholder': 'Search query&hellip;'|raw

but it still escapes &, outputting "Search query&hellip;" again.
Thanks in advance

A:

You can use the filter tag like this:
{% filter format('&hellip;')|raw %}
{{ form_widget(searchForm.query, {
    'type': 'search',
    'attr': {
        'placeholder': 'Search query%s'
    }
} ) }}    
{% endfilter %}

with %s instead of &hellip; in the value of placeholder
if you don't want use %s you can use replace instead of format with your own value (foo for example) :
{% filter replace({'foo': '&hellip;'})|raw %}
{{ form_widget(searchForm.query, {
    'type': 'search',
    'attr': {
        'placeholder': 'Search queryfoo'
    }
} ) }}
{% endfilter %}

