I would like to include JavaScript inside a form widget in Symfony2, but quotes are escaped inside the JavaScript command, see:
{{ form_widget(form.sdf,
{ 'attr': { 'value': "document.MSketch.getMol('sdf');" } }
) }}
and the result I get:
<input type="hidden" id="form_sdf" name="form[sdf]" required="required" value="document.MSketch.getMol('sdf');" />
I have read this topic : Twig and autoescaping But autoescape false is not working when using it like this:
{% autoescape false %}
{{ form_widget(form.sdf,
{ 'attr': { 'value': "document.MSketch.getMol('sdf');" } }
) }}
{% endautoescape %}
How to have quotes?
EDIT: Using raw filter isn't helping:
{% set cmd = 'document.MSketch.getMol("sdf");' %}
{{ form_widget(form.sdf, { 'attr': { 'value': cmd|raw } } ) }}
But raw filter is working outside of the form_widget, so where is the problem?